diff --git a/src/guitastro/dates.py b/src/guitastro/dates.py index 06a7b73..58bfb88 100644 --- a/src/guitastro/dates.py +++ b/src/guitastro/dates.py @@ -1136,12 +1136,25 @@ class Date(GuitastroTools): if __name__ == "__main__": - example = 1 + default = 1 + example = input(f"Select the example (0 to 1) ({default}) ") + try: + example = int(example) + except: + example = default print("Example = {}".format(example)) - if example == 1: + if example == 0: """ - Difference coord angles + Get current julian day """ d = Date("now") print(f"Now: {d.iso()} JD={d.jd()}") + + if example == 1: + """ + Get ISO from julian day + """ + d = Date(2456789.3456) + print(f"Now: {d.iso()} JD={d.jd()}") + diff --git a/src/guitastro/ephemeris.py b/src/guitastro/ephemeris.py index 6701861..b42acdb 100644 --- a/src/guitastro/ephemeris.py +++ b/src/guitastro/ephemeris.py @@ -1193,7 +1193,7 @@ class Ephemeris(EphemerisException, GuitastroTools): relative_humidity = rel_humidity obswl = wavelength_nm * u.nm fn = FileNames() - fn.longitude(self.home.longitude) + fn.longitude = self.home.longitude # --- compute jd1, jd2 the limits of dates to compute the ephemeris if nsec == 86400: # - we compute ephemeris for all the night diff --git a/src/guitastro/filenames.py b/src/guitastro/filenames.py index 2f0e82e..9eb250c 100644 --- a/src/guitastro/filenames.py +++ b/src/guitastro/filenames.py @@ -161,7 +161,7 @@ class FileNames(FileNamesException, GuitastroTools): :: fn = FileNames() - fn.longitude(-90) + fn.longitude = -90 night = "20230506" jd1, jd2 = fn.night2date(night) @@ -174,12 +174,12 @@ class FileNames(FileNamesException, GuitastroTools): the method date2night() returns a string corresponding to the night directory according an input date (i.e. DATE-OBS). The method date2night() consider a night as from noon to noon. To do that, before using date2night() - you must specify the longitude of the observatory with the method longitude(). + you must specify the longitude of the observatory with the attribute longitude. :: fn = FileNames() - fn.longitude(-90) + fn.longitude = -90 date = "2023-06-12T23:02:45" night = fn.date2night(date) @@ -350,6 +350,7 @@ class FileNames(FileNamesException, GuitastroTools): # --- naming_rule if len(args) > 0 : self.naming(args[0]) + self.longitude = 0 def __repr__(self): return str(self) @@ -368,7 +369,10 @@ class FileNames(FileNamesException, GuitastroTools): msg += f"\nExtension: {self.extension}" return msg - def longitude(self, longiau_deg:float): + def _get_longitude(self): + return self._longiau_deg + + def _set_longitude(self, longiau_deg:float): """ Set the longitude of the observation siteobs. This method is useful for the method get_night(). @@ -380,11 +384,13 @@ class FileNames(FileNamesException, GuitastroTools): :: ima1 = Ima() - ima1.longitude(2.3456) + ima1.longitude = 2.3456 """ self._longiau_deg = longiau_deg + longitude = property(_get_longitude, _set_longitude) + # ============================================= # Print filters # ============================================= @@ -2351,7 +2357,7 @@ class FileNames(FileNamesException, GuitastroTools): fn = FileNames() fn.pathing("YYYY/MM/DD") - fn.longitude(45.678) + fn.longitude = 45.678 param = {} param['date'] = "2021-10-26T13:45:23" param['night'] = True @@ -2507,7 +2513,7 @@ class FileNames(FileNamesException, GuitastroTools): fn = FileNames() fn.pathnaming("PyROS.img.1") - fn.longitude(45.678) + fn.longitude = 45.678 date = "2021-10-26T13:45:23" fnd = fn.naming_date(date) pparam = {} @@ -2645,7 +2651,7 @@ class FileNames(FileNamesException, GuitastroTools): def date2night(self, date: str="now", sampling: int=0)->str: """Get the current night identifier as a string of 8 characters: YYYYMMDD. - The night identifier changes at local noon. So it uses the longitude defined in longitude() method. + The night identifier changes at local noon. So it uses the longitude defined in longitude attribute. Args: date: Input date to compute the night identifier. Defaut value is "now". @@ -2705,7 +2711,7 @@ class FileNames(FileNamesException, GuitastroTools): def night2date(self, night: str="now")->str: """Get the current julian day limits from a night identifier as a string of 8 characters: YYYYMMDD. - The night identifier changes at local noon. So it uses the longitude defined in longitude() method. + The night identifier changes at local noon. So it uses the longitude defined in longitude attribute. Args: date: The night identifier string YYYYMMDD or a date (default is "now"). @@ -2995,7 +3001,7 @@ class FileNames(FileNamesException, GuitastroTools): :: fn = FileNames() - fn.longitude(165.85944) + fn.longitude = 165.85944 fn.fcontext_create("my_context", "Test") fn.fcontext = "my_context" fn.rootdir = "/tmp" @@ -3896,7 +3902,7 @@ if __name__ == "__main__": fn = FileNames() fn.pathing("YYYY/MM/DD") params = fn.pathing_get("/tmp/2023/01/04") - fn.longitude(45.678) + fn.longitude = 45.678 param = {} param['date'] = params['date'] param['night'] = False @@ -3906,7 +3912,7 @@ if __name__ == "__main__": fn = FileNames() fn.pathing("YYYY/YYYYMMDD") - fn.longitude(45.678) + fn.longitude = 45.678 param = {} param['date'] = "2021-10-26T13:45:23" param['night'] = True @@ -3917,7 +3923,7 @@ if __name__ == "__main__": """ fn = FileNames() fn.pathnaming("PyROS.img.1") - fn.longitude(45.678) + fn.longitude = 45.678 date = "2021-10-26T13:45:23" fnd = fn.naming_date(date) pparam = {} @@ -3941,7 +3947,7 @@ if __name__ == "__main__": """ fn = FileNames() fn.naming("T1M.1") - fn.longitude(45.678) + fn.longitude = 45.678 date = "2021-10-26T13:45:23" fnd = fn.naming_date(date) fparam = {} @@ -3974,7 +3980,7 @@ if __name__ == "__main__": """ fn = FileNames() longitude= -90 - fn.longitude(longitude) + fn.longitude = longitude print(f"longitude = {longitude}") # --- Define a date of the observation date = "2023-03-20T17:00:00" @@ -3993,7 +3999,7 @@ if __name__ == "__main__": Get path from name """ fn = FileNames() - fn.longitude(45.678) + fn.longitude = 45.678 fn.fcontext = "image_raw" fn.pathnaming("PyROS.img.1") fn.rootdir = "/tmp" @@ -4055,7 +4061,7 @@ if __name__ == "__main__": Manage many contexts for PyROS """ fn = FileNames() - fn.longitude(165.85944) + fn.longitude = 165.85944 # --- Create a file context for L0 images fn.fcontext_create("pyros_img_L0", "Images L0A") -- libgit2 0.21.2