pmelchior / skymapper

Mapping astronomical survey data on the sky, handsomely
MIT License
47 stars 15 forks source link

Not able to use type text with ra/dec infomation. #25

Closed oxno2 closed 5 years ago

oxno2 commented 5 years ago

Hi:

I tried to use Skymapper to draw Orion constellation. However, I failed to name the stars with map.text()

TypeError                                 Traceback (most recent call last)
<ipython-input-20-1745daa57a82> in <module>
      4 mapx.grid(sep = sep,c='red',lw=4)
      5 mapx.scatter(ra,dec,s= (8-t_ori['Vmag'])**3, c=color,edgecolor=color, facecolor='white')
----> 6 mapx.text(ra[0],dec[0],s='s')
      7 
      8 mapx.focus(ra,dec)

~/anaconda3/envs/astroconda/lib/python3.6/site-packages/skymapper/map.py in text(self, ra, dec, s, rotation, direction, **kwargs)
   1033             **kwargs: styling arguments for `matplotlib.text`
   1034         """
-> 1035         x, y = self.proj.transform(ra, dec)
   1036 
   1037         if rotation is None:

~/anaconda3/envs/astroconda/lib/python3.6/site-packages/skymapper/projection.py in transform(self, lon, lat)
    447 
    448     def transform(self, lon, lat):
--> 449         lon_ = self._standardize(lon)
    450         # Snyder 1987, eq 14-1 to 14-4
    451         theta = self.n * lon_

~/anaconda3/envs/astroconda/lib/python3.6/site-packages/skymapper/projection.py in _standardize(self, lon)
    196             lon_ *= -1 # left-handed
    197         # check that lon_ is between -180 and 180 deg
--> 198         lon_[lon_ < -180 ] += 360
    199         lon_[lon_ > 180 ] -= 360
    200         return lon_

TypeError: 'numpy.float64' object does not support item assignment

I cannot import skymapper.survey.DES, too.

oxno2 commented 5 years ago

Also, from the plot. There are multiple parallel straight lines, which I want to avoid.

tt

pmelchior commented 5 years ago

Thanks for the report. I fixed the problem with text.

As for the surveys, you need pymangle to work with the polygon definition of survey footprints. Can be installed with pip.

For the last problem: You seem to want to draw grid lines. That's what the grid method does for you. The problem with a direct approach is that the RA direction is broken, namely at +-180 degrees from the center of the map. It's inevitable since we map a sphere onto a finite figure. grid and several other methods in skymapper know about the non-contiguous nature of RA coordinates and treat graphics elements accordingly.