astropy / astroplan

Observation planning package for astronomers – maintainer @bmorris3
https://astroplan.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
199 stars 109 forks source link

issue with astroplan.observer #519

Closed educrot closed 1 year ago

educrot commented 2 years ago

It seems that some astroplan.observer's functions do not work for me anymore. However, all was fine yesterday.

For each function related to sun rise/set times or target set/rise times I get the following error:

~/elsenv/lib/python3.8/site-packages/astropy/units/decorators.py in wrapper(*func_args, **func_kwargs)
    232             # Call the original function with any equivalencies in force.
    233             with add_enabled_equivalencies(self.equivalencies):
--> 234                 return_ = wrapped_function(*func_args, **func_kwargs)
    235             if wrapped_signature.return_annotation not in (inspect.Signature.empty, None):
    236                 return return_.to(wrapped_signature.return_annotation)

~/elsenv/lib/python3.8/site-packages/astroplan/observer.py in target_is_up(self, time, target, horizon, return_altaz, grid_times_targets)
   1799             time = Time(time)
   1800 
-> 1801         altaz = self.altaz(time, target, grid_times_targets=grid_times_targets)
   1802         observable = altaz.alt > horizon
   1803 

~/elsenv/lib/python3.8/site-packages/astroplan/observer.py in altaz(self, time, target, obswl, grid_times_targets)
    495             return altaz_frame
    496         else:
--> 497             return target.transform_to(altaz_frame)
    498 
    499     def parallactic_angle(self, time, target, grid_times_targets=False):

~/elsenv/lib/python3.8/site-packages/astropy/coordinates/sky_coordinate.py in transform_to(self, frame, merge_attributes)
    441         # Do the transformation, returning a coordinate frame of the desired
    442         # final type (not generic).
--> 443         new_coord = trans(self.frame, generic_frame)
    444 
    445         # Finally make the new SkyCoord object from the `new_coord` and

~/elsenv/lib/python3.8/site-packages/astropy/coordinates/transformations.py in __call__(self, fromcoord, toframe)
   1390 
   1391             curr_toframe = t.tosys(**frattrs)
-> 1392             curr_coord = t(curr_coord, curr_toframe)
   1393 
   1394         # this is safe even in the case where self.transforms is empty, because

~/elsenv/lib/python3.8/site-packages/astropy/coordinates/transformations.py in __call__(self, fromcoord, toframe)
    993             return reprwithoutdiff.realize_frame(reprwithdiff)
    994         else:
--> 995             return supcall(fromcoord, toframe)
    996 
    997 

~/elsenv/lib/python3.8/site-packages/astropy/coordinates/builtin_frames/cirs_observed_transforms.py in cirs_to_altaz(cirs_coo, altaz_frame)
     49 
     50     lon, lat, height = altaz_frame.location.to_geodetic('WGS84')
---> 51     xp, yp = get_polar_motion(obstime)
     52 
     53     # first set up the astrometry context for CIRS<->AltAz

~/elsenv/lib/python3.8/site-packages/astropy/coordinates/builtin_frames/utils.py in get_polar_motion(time)
     39     """
     40     # Get the polar motion from the IERS table
---> 41     iers_table = iers.earth_orientation_table.get()
     42     xp, yp, status = iers_table.pm_xy(time, return_status=True)
     43 

~/elsenv/lib/python3.8/site-packages/astropy/utils/state.py in get(cls)
     38         Get the current science state value.
     39         """
---> 40         return cls.validate(cls._value)
     41 
     42     @classmethod

~/elsenv/lib/python3.8/site-packages/astropy/utils/iers/iers.py in validate(cls, value)
    854     def validate(cls, value):
    855         if value is None:
--> 856             value = IERS_Auto.open()
    857         if not isinstance(value, IERS):
    858             raise ValueError("earth_orientation_table requires an IERS Table.")

~/elsenv/lib/python3.8/site-packages/astropy/utils/iers/iers.py in open(cls)
    683             return cls.iers_table
    684 
--> 685         cls.iers_table = cls.read(file=filename)
    686         cls.iers_table.meta['data_url'] = all_urls[0]
    687 

~/elsenv/lib/python3.8/site-packages/astropy/utils/iers/iers.py in read(cls, file, readme)
    541             readme = IERS_A_README
    542 
--> 543         iers_a = super().read(file, format='cds', readme=readme)
    544 
    545         # Combine the A and B data for UT1-UTC and PM columns

~/elsenv/lib/python3.8/site-packages/astropy/table/connect.py in __call__(self, *args, **kwargs)
     50     def __call__(self, *args, **kwargs):
     51         cls = self._cls
---> 52         out = registry.read(cls, *args, **kwargs)
     53 
     54         # For some readers (e.g., ascii.ecsv), the returned `out` class is not

~/elsenv/lib/python3.8/site-packages/astropy/io/registry.py in read(cls, format, *args, **kwargs)
    521 
    522         reader = get_reader(format, cls)
--> 523         data = reader(*args, **kwargs)
    524 
    525         if not isinstance(data, cls):

~/elsenv/lib/python3.8/site-packages/astropy/io/ascii/connect.py in io_read(format, filename, **kwargs)
     16         format = re.sub(r'^ascii\.', '', format)
     17         kwargs['format'] = format
---> 18     return read(filename, **kwargs)
     19 
     20 

~/elsenv/lib/python3.8/site-packages/astropy/io/ascii/ui.py in read(table, guess, **kwargs)
    321         else:
    322             reader = get_reader(**new_kwargs)
--> 323             dat = reader.read(table)
    324             _read_trace.append({'kwargs': copy.deepcopy(new_kwargs),
    325                                 'Reader': reader.__class__,

~/elsenv/lib/python3.8/site-packages/astropy/io/ascii/cds.py in read(self, table)
    325                     return table
    326         else:
--> 327             return super().read(table)

~/elsenv/lib/python3.8/site-packages/astropy/io/ascii/core.py in read(self, table)
   1207             self.meta['table'].update(self.header.table_meta)
   1208 
-> 1209         table = self.outputter(cols, self.meta)
   1210         self.cols = self.header.cols
   1211 

~/elsenv/lib/python3.8/site-packages/astropy/io/ascii/core.py in __call__(self, cols, meta)
    988         # Sets col.data to numpy array and col.type to io.ascii Type class (e.g.
    989         # FloatType) for each col.
--> 990         self._convert_vals(cols)
    991 
    992         t_cols = [numpy.ma.MaskedArray(x.data, mask=x.mask)

~/elsenv/lib/python3.8/site-packages/astropy/io/ascii/core.py in _convert_vals(self, cols)
    973                     last_err = err
    974                 except IndexError:
--> 975                     raise ValueError(f'Column {col.name} failed to convert: {last_err}')
    976 
    977 

ValueError: Column year failed to convert: invalid literal for int() with base 10: '<!'

I have upgraded to the latest version of astroplan but this does not seem to solve the issue. Does anyone else encountered the same issue?

Thanks in advance !

bmorris3 commented 2 years ago

This is a known issue with astropy, see https://github.com/astropy/astropy/issues/12998.

bmorris3 commented 1 year ago

Closing since it looks like this issue has been fixed in astropy. Thanks again @educrot!