SS-Atlantis / AtlantisCmd

A command-line tool for doing various operations associated with managing runs of the Salish Sea Atlantis model. Based on https://github.com/SalishSeaCast/NEMO-Cmd/.
Apache License 2.0
0 stars 0 forks source link

Add -h flag for fisheries harvest .prm file #13

Closed douglatornell closed 2 years ago

douglatornell commented 2 years ago

re: issue #3

codecov[bot] commented 2 years ago

Codecov Report

Merging #13 (305d249) into main (0fbcf5f) will increase coverage by 0.05%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   93.69%   93.75%   +0.05%     
==========================================
  Files           7        7              
  Lines         428      432       +4     
  Branches       29       29              
==========================================
+ Hits          401      405       +4     
  Misses         24       24              
  Partials        3        3              
Flag Coverage Δ
unittests 93.75% <100.00%> (+0.05%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
atlantis_cmd/run.py 83.78% <ø> (ø)
tests/conftest.py 98.66% <100.00%> (+0.07%) :arrow_up:
tests/test_run.py 98.11% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

douglatornell commented 2 years ago

Because the harvest file is a .prm file, the implementation is a little different (and slightly simpler) than for species migrations. The files in the parameters: section of the YAML file get handled by a loop. So, I set things up so that you add a line like:

harvest: /ocean/$USER/Atlantis/salish-sea-atlantis-model/SS_harvest.prm

to the parameters: section. Order doesn't matter, but I put it below biology: in the example YAML.

The file name on the right can be anything you want. In the run and results directories the file will be called harvest.prm. I can change that to something else if you want.

Per your comment yesterday, once we merge this there will have to be a harvest item in every YAML file you run, and you will have to control whether or not it is used in your run.prm file. That is because the command to run Atlantis in the Atlantis.sh file will always include -h harvest.prm.

douglatornell commented 2 years ago

If you want to test this before I merge the PR, you can. It will involve a bit of git branch switching. I'm happy to talk you through it.

Or, I can go ahead and merge, and deal with anything that I messed up when you find it.

Your choice...

raishalovindeer commented 2 years ago

Let's test it on the branch, and yes I will need your help with switching branches. Not sure how this connects to my current environment.

raishalovindeer commented 2 years ago

So it seems there is an additional file that is needed when running with fisheries turned on. I got the following error in Atlantis:

ERROR. Util_Read_Fisheries_XML: Trying to read in the fishery definition file, but no file was provided.

See the -q option below.

Util_Usage: atlantis -i input.nc dump -o output.nc -r run.prm -f force.prm -p physics.prm -b biology.prm -m migration.csv -h harvest.prm -a assess.prm -e economics.prm -s functionGroupFile.xml -q fisheries.xml [-d destinationFolder] [-t inputFolder]

Looking into the salish-sea-atlantis-model repo I see a fisheries.csv file that was added in May this year. I suspect we need to include that (the notation for Atlantis says .xml, but note that our fisheries file is actually .csv)

douglatornell commented 2 years ago

Okay. I'll add fisheries.csv in the same way that we have species migrations (another "top level" line in the YAML). I can't do it in the parameters: section because the loop that is used for those files forces them copied as .prm files. I think it would be chaotic-evil to have fisheries.csv turn into fixheries.prm :smiling_imp:

raishalovindeer commented 2 years ago

😄 I concur.

douglatornell commented 2 years ago

Ready for another test!

git pull should pull in the new commit on this branch.

Add a line like:

fisheries: /ocean/$USER/Atlantis/salish-sea-atlantis-model/SalishFisheries.csv

below the migrations: line in your YAML file (though order doesn't matter), and let's see how much farther it gets.

raishalovindeer commented 2 years ago

Done. The test simulation is off and running, having found all the required flags and files. From the output, I can see that Atlantis is reading parameters from the harvest file, so we have success!

douglatornell commented 2 years ago

You can do:

git switch main
git pull
git branch -d harvest-flag

to get back to the main branch, pull in the changes in this PR that have now been merged there, and delete the now irrelevant harvest-flag local branch in your workspace.