Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karr/update interface #50

Merged
merged 20 commits into from
Sep 26, 2024
Merged

Karr/update interface #50

merged 20 commits into from
Sep 26, 2024

Conversation

JenniferKarr
Copy link
Contributor

Some fairly major updates for the simulations

Command Line

  • added --sequence command line option which lets you explicitly set a start time and increment the observing dates from there, or increment from the first date in the YAML file
  • added --doCalib=N command line option which will determine which darks and flats need to be performed, and will simulate N of each at the end of the sequence, automatically updating the observing date
  • added some test of YAML file inputs, checking for data types and presence of required keywords; will exit if any entry fails
  • added --testRun command line option which just prints diagnostics and doesn't actually run simulate
  • tidied input format a bit

YAML keyworlds

  • removed the mjdobs expansion, replaced with nObs for number of observations of each type
  • changed prefix keyword to do.catg, which is what it actually is

Structure

  • separated download of packages to routine download.py, which can be executed as part of the installation process
  • separated sources from simulationDefinitions.py, to make it easier for people to create their own sources
  • automatically call updateHeaders.py at the end of the script, unless --testRun is set

@hugobuddel
Copy link
Contributor

It seems you branched from a very old version of the repository. See git log --graph --oneline --all:

* d9a9c2a (origin/karr/updateInterface) Tidied command line options
* 907c63d fixed links
* 102af3c Some more quality of life fixes.
* 314e488 Some major updates to the calling of run_recipes.
* 66ac6c5 (origin/ifuHack) yamls for testing pycpl
| *   1e8a178 (origin/main, origin/HEAD) Merge pull request #48 from AstarVienna/oc/run_types
| |\  
| | * b123e40 here's to automatic testing
| | * 10c849f Rename parameter to catg
| | * 550c456 missed an obvious test
| | * e3db589 add parameter --procatg
| |/  
| *   34a7ef1 Merge pull request #47 from AstarVienna/dependabot/pip/zipp-3.19.1
| |\  
| | * b3ee4d0 Bump zipp from 3.18.1 to 3.19.1
| |/  
| *   f36acd1 Merge pull request #46 from AstarVienna/dependabot/pip/certifi-2024.7.4
| |\  
| | * 6b3f7df Bump certifi from 2024.2.2 to 2024.7.4
| |/  
| *   5210401 Merge pull request #44 from AstarVienna/template
| |\  
| | *   6956ef9 (origin/template) Merge pull request #45 from AstarVienna/hb/comparetemplateswithdrld
| | |\  
| | | * 7925ddd (HEAD -> hb/comparetemplateswithdrld, origin/hb/comparetemplateswithdrld) Also compare the tplname in the recipes.yaml against the DRLD
| | |/  
| | * 9d766b0 (template) Added tplname to recipes.yaml to vary the templates in the headers of the simulated data.
| |/  
| *   cc3962d (main) Merge pull request #42 from AstarVienna/cy/issue-41
| |\  
| | * c9b60e6 Remove try - except block
| | * 49b19bb Better try - except block
| | * 5ec6736 (origin/cy/issue-41) Check MJD-OBS type before updating
| | * 85bf55e Updating gitignore
| |/  
| *   2be93ca Merge pull request #39 from AstarVienna/mjdobs
| |\  
| | * e26bf4c (origin/mjdobs) Convert mjdobs from isot to mjd in updateheaders
| |/  
| *   6ab8f48 Merge pull request #37 from AstarVienna/hb/comparewithdrld
| |\  
| | * 866515a Add workaround for "LMS"
| | * 3ca28d3 Replace IFU with LMS again for updateHeaders.py to work
| | * e483b90 Use IFU_SKY_RAW also for observations of standard star
| | * ff59e37 Use the correct DPR.TECH keywords in updateHeaders.py
| | * f7d84ea Add workaround for TECH keywords that are updated in updateHeaders.py
| | * 4985944 Put RAVC,IFU back, fixed in updateHeaders.py
| | * ac1b0ba Add IFU_SKY_RAW
| | * 789f5df Also check whether all RAW dataitems are actually simulated
| | * aee6d75 Put N_IMAGE_SCI_RAW in N and LM_IMAGE_SCI_RAW in LM
| | * a266735 Some more DPR keyword changes
| | * 06ff7b2 Comment out IFU_RSRF_PINH_RAW, because it does not exist in the DRLD
| | * f26dc58 Remove IFU Flats, because these do not exist.
| | * 77c2486 DARK and DETLIN use 2RG and GEO instead of LM and N
| | * 81b0976 Various change to make recipes.yaml compatible with DRLD
| | * c8dd5ac Various changes to make recipes.yaml compliant to DRLD
| | * 7a43709 Add script to compare keywords with DRLD
| | * d631d0e Ignore temporary files, .idea, and inst_pkgs
| |/  
|/|   
| * 15a8621 Merge pull request #38 from AstarVienna/dependabot/pip/urllib3-2.2.2
|/| 
| * 0a2e501 Bump urllib3 from 2.2.1 to 2.2.2
|/  
*   2d7725a Merge pull request #21 from AstarVienna/dependabot/pip/requests-2.32.0
|\  
| * 439401c --- updated-dependencies: - dependency-name: requests   dependency-type: indirect ...
|/  
* 79264c4 (tag: v2024.05.14) Update checksums, also rename file to match README
* ...

perhaps you could try to rebase the branch, or merge main into it?

@hugobuddel
Copy link
Contributor

A small note about do.catg, that is indeed the term we use in the DRLD. However, I believe DO.CATG is an outdated term. The DO stands for "Data Organizer", a piece of software that will be replaced by the EDPS. So maybe we should also try to not use the term. In #48 we settled for just catg. But perhaps it is not worth it to change it now.

MJDOBS Determination
--------------------

The date of observation is now determined as follows

 - if --sequence is set to a date in the format yyyy-mm-dd hh:mm:ss
   the code will start from that date and increment based on
   observing time of the previous call to simulate.

 - if --sequence = 1, the observations will start from the date
   given in the first entry in the YAML file

 - if --sequence is not set, the observations will take the date
   directly from the YAML file. If an entry other than the first one
   doesn't have mjdobs in the YAML entry, the observation time will
   be incremented as above.

mjdObs is no longer an expandable.

Instead, there is a new paramter, nObs, in the YAML file. nObs observations
of each combination in the entry will be generated with sequential timestamps,
based either on the previous exposure or the mjdObs value depending
on the --sequence options.

e.g.

>

CALIBRATION FILES
-----------------

If the option --doCalib is set to an integer > 0, the script will determine
what combination of darks and flats need to be observed as part of the sequence of
observations, and will execute them at the end of the observations given in the
YAML file.

At the moment, DARK,WCUOFF files are not included; they may be added later.

The value of doCalib, if > 0, determines the number of each type to be
execute.

DEBUGGING
---------

Some more informative output is written to the screen; the values of the
run time options, and the parameters of each call to simulate().

If the command line option --testRun is set, the script will be run,
the YAML file parsed, and mdjObs calculated, but simulate() will not
be called. This is intended for debugging and checking input.

Added a routine checking the YAML file for valid input. It will check that
mode, prefix, properties, dit, ndit, filter_name, catg, tech, type, nObs exist,
check that ndit and nObs are positive integers, dit a positive number,
and for valid values of mode, catg, tech, type (as imported from simulationDefinitions).
If invalid input is detected, an error message is written and the code aborts.

Currently filter_name, ndfilter_name or source are not checked.

PREFIX
------

This was set before, but to highlight the change. Each YAML entry now
has a prefix field in addition to mode, because the labels for each
recipe need to be unique, while the prefix to the output file does not.
prefix is solely used to label the entries; mode is used for generating
file names and setting DO.CATG.
- separated downloads into downloads.py, to be run after installing
  and if the packages need updating.

- automatically call updateHeaders at the end of the script

- separated simulationDefinitions from sources

- changed the prefix parameter to do.catg, which is what it should be.

- significant rewrite of README
    - updated installation / basic run instructions
    - more extensive command line options section
    - added section describing how to run your own simulations
Changed mjdobs to dateobs because it's not actually MJD

updateHeaders.py won't be called if --testRun is set

updated README to match
@JenniferKarr
Copy link
Contributor Author

I've rebased to master, ran the code locally, and tidied the recipes.yaml afterwards. The automated tests need to be updated to run downloads.py before run_recipes.py, to download the necessary packages.

Copy link
Contributor

@hugobuddel hugobuddel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I run ./run_recipes.py, it will give several warnings, but not actually simulate anything it seems:

$ ./run_recipes.py 
Starting Simulations
   input YAML = [...]/METIS_Simulations/ESO/recipes.yaml, output directory =  [...]/METIS_Simulations/ESO/output
  Observation dates will be taken from YAML file if given
  Automatically generated darks and flats 0
  Small output option False
Recipe LM_SLITLOSSES_RAW1 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW2 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW3 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW4 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW5 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW6 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW7 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW8 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW9 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW10 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW11 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW1 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW2 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW3 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW4 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW5 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW6 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW7 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW8 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW9 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW10 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW11 has invalid TYPE of SLITLOSS)
[...]/METIS_Simulations/ESO/recipes.yaml [...]/METIS_Simulations/ESO/output False None
Recipe LM_SLITLOSSES_RAW1 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW2 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW3 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW4 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW5 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW6 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW7 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW8 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW9 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW10 has invalid TYPE of SLITLOSS)
Recipe LM_SLITLOSSES_RAW11 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW1 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW2 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW3 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW4 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW5 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW6 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW7 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW8 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW9 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW10 has invalid TYPE of SLITLOSS)
Recipe N_LSS_SLITLOSSES_RAW11 has invalid TYPE of SLITLOSS)

ESO/README.md Outdated Show resolved Hide resolved
ESO/README.md Outdated Show resolved Hide resolved
ESO/README.md Outdated Show resolved Hide resolved
ESO/README.md Outdated Show resolved Hide resolved
ESO/run_recipes.py Outdated Show resolved Hide resolved
ESO/run_recipes.py Outdated Show resolved Hide resolved
ESO/downloads.py Outdated Show resolved Hide resolved
@hugobuddel
Copy link
Contributor

I've rebased to master, ran the code locally, and tidied the recipes.yaml afterwards.

Thanks!

The automated tests need to be updated to run downloads.py before run_recipes.py, to download the necessary packages.

I interpreted this as that you were still going to update the tests before asking for a review. But I reviewed the code anyway. Could you please update the tests?

I think we should have at least someone be able to replicate the simulation run, I couldn't yet do it.

reworked handling of automatically generated flats/darks to use a list of dictionaries in the same form as that read from the YAML file, rather than hard to parse lists and sets.  This includes the definition template dictionaries in simulationDefinitions.py.
@JenniferKarr
Copy link
Contributor Author

I've addressed the various comments as written, with the exception of reworking the generation of the set of flats/darks to use a list of dictionaries rather than various impenetrable set/list combinations. This is easier to follow and more compact.

To address two comments:

The N band laser is available only during AIT, as per the DRLD.

I kept use of do.catg, as we already use catg in the template definition, for the CALIB, etc.

@hugobuddel
Copy link
Contributor

Great thanks. I'm running the simulations now!

Note that this page (#50) shows all the unresolved comments in a nice overview, and just scrolling up shows that there are 5 still open. (I marked some as resolved.) These comments are mostly small ones, and can easily be resolved by pressing the 'Commit suggestion' button. But I don't want to press that button myself because doing so would change 'your' branch on github, which you might find annoying if it happens unexpectedly.

Could you therefore go over these suggestions?

Copy link
Contributor

@hugobuddel hugobuddel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, since I can now run the code, and the tests run too. And of course it is a big improvement! I did not yet verify whether I get the same hashes though.

I would appreciate it though if you could still go through the small suggestions I made; it shouldn't take more than a few minutes.

JenniferKarr and others added 4 commits September 25, 2024 16:46
Co-authored-by: Hugo Buddelmeijer <[email protected]>
Co-authored-by: Hugo Buddelmeijer <[email protected]>
Co-authored-by: Hugo Buddelmeijer <[email protected]>
Co-authored-by: Hugo Buddelmeijer <[email protected]>
Co-authored-by: Hugo Buddelmeijer <[email protected]>
@JenniferKarr JenniferKarr merged commit be522a7 into main Sep 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants