desihub / desisurvey

Code for desi survey planning and implementation
BSD 3-Clause "New" or "Revised" License
2 stars 7 forks source link

Cached ephemerides strings have different dtype #28

Closed mlandriau closed 7 years ago

mlandriau commented 7 years ago

When created, the 'dirname' part of the calendar is of type 'S8' if computed, but 'U8' if read from file. This causes en error in the line 281 of afternoonplan.py:

filename = 'obsplan' + day_stats['dirName'].decode('ascii') + '.fits'

When read from file, the line should not have the .decode('ascii') .

sbailey commented 7 years ago

bytes vs. unicode in python 3 is such a pain.

Ideally the caching and I/O should be implemented such that the object returned from getCalAll is identical regardless of whether it was created on-the-fly or read from a cache. i.e. please fix it within getCalAll so that other code doesn't have to know whether it was from a cache or not.

dkirkby commented 7 years ago

Let's drop the string entirely from the ephemerides file, since it doesn't really belong there, and compute it on the fly from day with:

'{y:04d}{m:02d}{d:02d}'.format(y=day.year, m=day.month, d=day.day)

I will make this change on my branch unless someone objects.

dkirkby commented 7 years ago

This was fixed in #30