Portugal has a long tradition of representing armillary spheres in its flags, but it was around the end of 17th century when a white ensign with armillary sphere was established to identify the ships authorized to American colonies trade. In Brazil, this pavilion ended up being identified as own and becoming the basis of the current national flag. On the other hand, the armillary sphere itself was later incorporated into Portugal's own modern flag and coat of arms.
Sources: Anonymous manuscript from 1670, reprinted in Amsterdam 1966 as «Flags of the World 1669-1670» | Wikipedia(pt):Evolução da bandeira de Portugal
Sizes: ensign W12 x L18 mm, mast flags W8 x L12 mm, jack W6 x L9 mm, pennant W4 x L48 mm.