-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathschedule_run.py
72 lines (63 loc) · 2.92 KB
/
schedule_run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
""" main.py is the main routine calling surveysim for tests"""
# eval "$(pyenv init -)";
#%load_ext autoreload
#%autoreload 2
#import os
#os.environ["LVMCORE_DIR"] = "/Users/droryn/prog/lvm/lvmcore/"
#https://in-the-sky.org/skymap2.php?year=2019&month=11&day=11&town=3884373
#https://lambda.gsfc.nasa.gov/product/foreground/fg_halpha_get.cfm
from lvmsurveysim.schedule import ObservingPlan, Simulator, TileDB, OpsDB
from lvmsurveysim.target import TargetList
import matplotlib.pyplot as plt
def run(targets='./targets.yaml', tile=False, sim=False, plot=False, save=False):
# Creates a list of targets/
print('Creating target list ...')
targets = TargetList(target_file='./targets.yaml')
# Create tile database
OpsDB.init()
if tile:
print('Tiling Survey ...')
tiledb = TileDB(targets)
tiledb.tile_targets()
OpsDB.create_tables(drop=True)
OpsDB.save_tiledb(tiledb) #, fits=True, path='lco_tiledb', overwrite=True)
else:
print('Loading tile database ...')
#tiledb = OpsDB.load_tiledb(path='lco_tiledb', fits=True)
tiledb = OpsDB.load_tiledb()
# Creates observing plans for LCO for the range sep 2021 - jun 2025.
# http://www.csgnetwork.com/julianmodifdateconv.html
print('Creating observing plan ...')
#lco_plan = ObservingPlan(2459458, 2460856, observatory='LCO') # baseline 2021
#lco_plan = ObservingPlan(2459945, 2459945+365*3+182, observatory='LCO') # baseline 2023, 3.5yr
#lco_plan = ObservingPlan(2459945, 2461555, observatory='LCO') # baseline Jan 2023, until 30-May-2027
lco_plan = ObservingPlan(2460096, 2461555, observatory='LCO') # baseline Jun 2023, until 30-May-2027
if sim:
# Creates an Simulator instance and runs the simulation
print('Creating Simulator ...')
sim = Simulator(tiledb, observing_plan=lco_plan)
sim.run(progress_bar=True)
# Load/Save from as FITS table in a later session, no need to rerun:
# sim = Simulator.load('LCO_2023_4', 'lco_tiledb')
sim.save('LCO_2023_5', overwrite=True) # Save as FITS table
if plot:
plot_survey(sim, basename='LCO_2023_5', save=save)
return sim
def plot_survey(sim, basename='LCO_2023_5', save=False):
# Plot and print:
sim.print_statistics()
sim.plot_survey('LCO', use_groups=True)
if save: plt.savefig(basename+'_jd.pdf')
sim.plot_survey('LCO', use_groups=True, cumulative=True)
if save: plt.savefig(basename+'_cumulative.pdf')
sim.plot_survey('LCO', lst=True, use_groups=True)
if save: plt.savefig(basename+'_lst.pdf')
sim.plot(fast=True) # footprint
if save: plt.savefig(basename+'_survey.pdf')
sim.plot_airmass(tname='ALL', group=True, norm=True)
if save: plt.savefig(basename+'_airmass.pdf')
sim.plot_shadow_height(tname='ALL', group=True, norm=True, cumulative=True, linear_log=True)
if save: plt.savefig(basename+'_hz.pdf')
#if save: sim.animate_survey(filename='lvm_survey_hz_2023.mp4')
if not save:
plt.show()