def midnight(self, utc, jd=False): try: if jd: return self._obs_.midnight(tm(utc)).jd else: return self._obs_.midnight(tm(utc)).datetime except Exception as excpt: self.logger.log(excpt)
def now(self, utc=True): try: if utc: return tm(datetime.utcnow(), scale='utc') else: return tm(datetime.now()) except Exception as excpt: self.logger.log(excpt)
def midnight(self, utc, jd=False): self.logger.info(f"Returning midnight time") try: if jd: return self._obs_.midnight(tm(utc)).jd else: return self._obs_.midnight(tm(utc)).datetime except Exception as excpt: self.logger.error(excpt)
def now(self, utc=True): self.logger.info(f"Getting now") try: if utc: return tm(datetime.utcnow(), scale='utc') else: return tm(datetime.now()) except Exception as e: self.logger.error(e)
def jd_r(self, jd): """JD to Time calculator""" try: t = tm(jd, format='jd', scale='tai') return t.to_datetime() except Exception as excpt: self.logger.log(excpt)
def jd2hjd(self, jd, ra, dec): obj = SkyCoord(ra, dec, unit=(U.hourangle, U.deg), frame='icrs') greenwich = EarthLocation.of_site('greenwich') jd = tm(jd, format="jd", location=greenwich) ltt_helio = jd.light_travel_time(obj, 'heliocentric') return jd + ltt_helio
def jd_r(self, jd): """Returns UTC from JD""" try: t = tm(jd, format='jd', scale='tai') return t.to_datetime() except Exception as e: self.logger.error(e)
def jd(self, utc): """JD calculator""" try: t = tm(utc, scale='utc') return t.jd except Exception as excpt: self.logger.log(excpt)
def altaz(self, site, obj, utc): """Return AltAz for a given object and time for this site""" try: frame_of_site = AltAz(obstime=tm(utc), location=site) object_alt_az = obj.transform_to(frame_of_site) return object_alt_az except Exception as e: self.logger.error(e)
def jd_r(self, jd): """JD to Time calculator""" self.logger.info(f"Calculating date from {jd}") try: t = tm(jd, format='jd', scale='tai') return t.to_datetime() except Exception as excpt: self.logger.error(excpt)
def jd2bjd(self, jd, ra, dec): obj = SkyCoord(ra, dec, unit=(U.hourangle, U.deg), frame='icrs') greenwich = EarthLocation.of_site('greenwich') self.logger.warning("JD: {}".format(jd)) jd = tm(jd, format="jd", location=greenwich) ltt_bary = jd.light_travel_time(obj) return jd + ltt_bary
def jd(self, utc): """JD calculator""" self.logger.info(f"Calculating jd from {utc}") try: t = tm(utc, scale='utc') return t.jd except Exception as excpt: self.logger.error(excpt)
def twilight_evening(self, utc, tp="ASTRONOMICAL", which="next", jd=False): try: which = self.__which_corrector__(which) if "CIVIL".startswith(tp.upper()): ret = self._obs_.twilight_evening_civil(tm(utc), which=which) elif "NAUTICAL".startswith(tp.upper()): ret = self._obs_.twilight_evening_nautical(tm(utc), which=which) else: ret = self._obs_.twilight_evening_astronomical(tm(utc), which=which) if jd: return ret.jd else: return ret.datetime except Exception as excpt: self.logger.log(excpt)
def jd(self, utc): """Calculates JD from UTC""" if utc is not None: try: ret = tm(utc, scale='utc') return ret.jd except Exception as e: self.logger.error(e) else: self.logger.warning("False Type: The value is not date")
def moon_set_time(self, utc, which="next", jd=False): try: which = self.__which_corrector__(which) moon_set = self._obs_.moon_set_time(tm(utc), which=which) if jd: return moon_set.jd else: return moon_set.datetime except Exception as excpt: self.logger.log(excpt)
def sun_rise_time(self, utc, which="next", jd=False): try: which = self.__which_corrector__(which) sun_rise = self._obs_.sun_rise_time(tm(utc), which=which) if jd: return sun_rise.jd else: return sun_rise.datetime except Exception as excpt: self.logger.log(excpt)
def sun_rise_time(self, utc, which="next", jd=False): self.logger.info(f"Calculating Sun Rise") try: which = self.__which_corrector__(which) sun_rise = self._obs_.sun_rise_time(tm(utc), which=which) if jd: return sun_rise.jd else: return sun_rise.datetime except Exception as excpt: self.logger.error(excpt)
def moon_set_time(self, utc, which="next", jd=False): self.logger.info(f"Calculating Moon Set") try: which = self.__which_corrector__(which) moon_set = self._obs_.moon_set_time(tm(utc), which=which) if jd: return moon_set.jd else: return moon_set.datetime except Exception as excpt: self.logger.error(excpt)
def create(self): try: return get_moon(tm(self._time_, scale='utc')) except Exception as excpt: self.logger.log(excpt)
def create(self): self.logger.info(f"Creating Moon Object") try: return get_moon(tm(self._time_, scale='utc')) except Exception as excpt: self.logger.error(excpt)
def update(self, time): self.logger.info(f"Updating Moon Object") try: return get_moon(tm(time, scale='utc')) except Exception as excpt: self.logger.error(excpt)
def is_night(self, utc): self.logger.info(f"Checking if is night {utc}") try: return self._obs_.is_night(tm(utc)) except Exception as excpt: self.logger.error(excpt)
def is_night(self, utc): try: return self._obs_.is_night(tm(utc)) except Exception as excpt: self.logger.log(excpt)
def update(self, time): try: return get_moon(tm(time, scale='utc')) except Exception as excpt: self.logger.log(excpt)