def sun_moon(self): lat, longit, elev = '34.7443', '-111.4223', 2361 loc = EarthLocation.from_geodetic(longit, lat, elev) dct = Observer(loc, timezone='US/Mountain') now = Time.now() altaz = AltAz(location=loc, obstime=now) sun = get_sun(now) moon = get_moon(now, loc) lst = dct.local_sidereal_time(now) lst = lst.hms lsth, lstm, lsts = str(lst[0]).split('.')[0], str( lst[1]).split('.')[0], str(lst[2]).split('.')[0] lstss = str(lst[2]).split('.')[1] self.lststr = '%02d' % int(lsth) + ':' + '%02d' % int( lstm) + ':' + '%02d' % int(lsts) + '.' + lstss[0:2] moonfz = dct.moon_illumination(now) self.moonillum = f'{moonfz * 100:04.1f}' moonget = moon.transform_to(altaz).alt.deg self.moonalt = '{:2.4f}'.format(moonget) sunget = sun.transform_to(altaz).alt.deg self.sunalt = '{:2.4f}'.format(sunget) return self.lststr, self.sunalt, self.moonalt, self.moonillum
time = Time('2019-12-26') #UTC midnight = Time(lokasi.midnight(time).iso) delta_md = np.linspace(-5, 5, 22) * u.hour win_time = midnight + delta_md night = win_time # day = (midnight + 12*u.hour) + delta_md day = (midnight + 12 * u.hour) + np.linspace(0, 3, 30) * u.hour # GMS op = pd.read_csv('op.csv', index_col='nama') ra = op.ra dec = op.dec sunset = lokasi.sun_set_time(time) sunrise = lokasi.sun_rise_time(time) moonrise = lokasi.moon_rise_time(time) moonset = lokasi.moon_set_time(time) moon_ill = lokasi.moon_illumination(time) moonaltaz = lokasi.moon_altaz(time) moonaltaz.name = 'moon' sunaltaz = lokasi.sun_altaz(time) sunaltaz.name = 'sun' def objek(nama, ra, dec): op = SkyCoord(ra, dec, frame='icrs', unit='deg') op_name = FixedTarget(coord=op, name=nama) # betelgeus = SkyCoord.from_name('betelgeuse') # altaz_frame = lokasi.altaz(time) # ubah lokasi pengamat ke altaz frame # betelgeus_altaz = betelgeus.transform_to(altaz_frame) # ubah target ke altaz altaz = lokasi.altaz(win_time, op) terbit = lokasi.target_rise_time(win_time, op) transit = lokasi.target_meridian_transit_time(win_time, op)
# evening (civil) twilight obs.twilight_evening_civil(time_obs) # morning (nautical) twilight obs.twilight_morning_nautical(time_obs) # morning (civil) twilight obs.twilight_morning_civil(time_obs) # morning (astronomical) twilight obs.twilight_morning_astronomical(time_obs) # what is the moon illumination? # returns a float, which is percentage of the moon illuminated obs.moon_illumination(time_obs) # what is the moon altitude and azimuth? obs.moon_altaz(time_obs) # Other sun-related convenience functions: obs.noon(time_obs, which='nearest') obs.midnight(time_obs, which='nearest') # ============== # Target objects # ============== ''' A target object defines a single observation target, with coordinates and an optional name. '''
# evening (civil) twilight obs.evening_civil(date=time_obs) # morning (nautical) twilight obs.morning_nautical(date=time_obs) # morning (civil) twilight obs.morning_civil(date=time_obs) # morning (astronomical) twilight obs.morning_astronomical(date=time_obs) # what is the moon illumination? # returns a float, which is percentage of the moon illuminated obs.moon_illumination(date=time_obs) # what is the moon altitude and azimuth? obs.moon_altaz(date=time_obs) # Other sun-related convenience functions: obs.noon(date=time_obs, which='nearest') obs.midnight(date=time_obs, which='nearest') # ============== # Target objects # ============== ''' A target object defines a single observation target, with coordinates and an optional name. '''