def greenwich_sidereal_time_in_radians(): """Calculate using GMT (according to client's time settings).""" #Function astropysics.obstools.epoch_to_jd wants a decimal year as input #Function astropysics.obstools.calendar_to_jd can take a datetime object gmt_jd = obstools.calendar_to_jd(site_time_gmt_as_datetime()) #Convert from hours to radians... 24hr = 2*pi return coords.greenwich_sidereal_time(gmt_jd) * pi / 12
def greenwich_sidereal_time_in_radians(): """Calculate using GMT (according to client's time settings).""" # Function astropysics.obstools.epoch_to_jd wants a decimal year as input # Function astropysics.obstools.calendar_to_jd can take a datetime object gmt_jd = obstools.calendar_to_jd(site_time_gmt_as_datetime()) # Convert from hours to radians... 24hr = 2*pi return coords.greenwich_sidereal_time(gmt_jd) * pi / 12
def getMonths(ra, dec): from astropysics.coords import AngularCoordinate, FK5Coordinates from astropysics.obstools import Site import astropysics.obstools as astobs # name, ra, dec = np.loadtxt('coords.dat', usecols=(0,1,2), dtype=str, unpack=True) kpnolat = AngularCoordinate('+31d57m12s') kpnolong = AngularCoordinate('-7h26m28.00s') kpnoelev = 2096.0 kpnooffs = -7 kpno = Site(kpnolat, kpnolong, alt=kpnoelev, tz=kpnooffs, name='KPNO') months = np.array([1,2,3,4,5,6,7,8,9,10,11,12]) days = np.array([7.0, 14.0, 21.0, 28.0]) monthDict = {1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug', 9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'} coords = FK5Coordinates(ra,dec) monthBool = [] for m in months: upMonth = [False, False, False, False] for j,day in enumerate(days): jd = astobs.calendar_to_jd((2016.0, float(m), day), tz=-7) r,s,t = kpno.riseSetTransit(coords, date=jd, alt=42.0) # print monthDict[m], day, r,s,t if r > 20.0 and s <= 8.0: nightHours = (24.0-r)+s elif 8.0 <= r <= 20.0 and s <= 8.0: nightHours = 4.0+s elif r > 20.0 and s >= 8.0: nightHours = (24.0-r)+8.0 elif r <= 20.0 and s >= 20.0: nightHours = s-20.0 elif 20.0 < r < s: nightHours = s-r elif r < s < 8.0: nightHours = s-r elif r <= 8.0 : nightHours = 8.0-r else : nightHours = 0.0 if nightHours >= 2.50: upNight = True upMonth[j] = True else: upNight = False monthBool.append(all(upMonth)) # print monthBool obsmonths = [] for m in months[np.where(monthBool)]: obsmonths.append(monthDict[m]) return obsmonths
def add_time_info(header, history=False): """ Add JD, MJD, LST to FITS header; `header` should be a pyfits header object. history : bool If `True`, write history for each keyword changed. Uses `feder.currentobsjd` as the date. """ dateobs = parse_dateobs(header['date-obs']) JD.value = round(obstools.calendar_to_jd(dateobs), 6) MJD.value = round(obstools.calendar_to_jd(dateobs, mjd=True), 6) # setting currentobsjd makes calls following it use that time # for calculations feder.currentobsjd = JD.value LST.value = feder.localSiderialTime() LST.value = sexagesimal_string(deg2dms(LST.value)) for keyword in keywords_for_all_files: keyword.addToHeader(header, history=history)