holos-aafc / Holos

Open source version of the core algorithms used by the Holos model
Other
19 stars 21 forks source link

Single command line call to process a farm #55

Open ramsaym opened 11 months ago

ramsaym commented 11 months ago

Feature request.

Could we configure the command line to be run in a linux environment to expose HOLOS as an API. Instead of going through each "yes/no", I'd like to be able to configure climate settings (currently a feature) and run a single command line, similar to in QGIS where you would use something like

Holos -dir -file <.json file to process or multiple files> -climate -output

Code of Conduct

UrsakiUleth commented 11 months ago

Hello @ramsaym,

I have implement a few command line input flags so you can bypass the CLI dialog.

-i indicates your input .json file. This is case sensitive and requires the file extension. -s indicates a configured .settings file. This is also case sensitive and requires the file extension. -u indicates your chosen unit of measurement, metric or imperial. This is not case sensitive.

Though these flags are option, note that if you use them, the first argument must be the directory to the folder containing your input and settings file. There is no input flag for this directory. Note that the -s flag is only available if the -i flag is also used.

I've yet to implement an input flag for output folder.

The H.CLI executable will be found with the H.CLI/bin/debug folder in your local repo.

Here's an example of a command with arguments you can run:

H.CLI -i input.json -s farm.settings -u metric

Note that your input and settings file must be within the directory provided.

UrsakiUleth commented 11 months ago

I do need clarification as to what you wish to provide as input for climate settings.

Currently you can configure climate settings manually within the .settings file that is generated when a farm is imported.

Do you want the climate input to be a manually configured settings file? If so, you can use the -s flag.

Or do you want climate input to be an argument that modifies the .settings file generated on import?

ramsaym commented 11 months ago

apologies on the delay. I would think it easiest to create a flag for the SLC polygon ID and derive the climate data from that. Does that work. Also, I am still getting a request to enter parameters even when I use the flags from the bin/DEbug folder

image

ramsaym commented 11 months ago

image

UrsakiUleth commented 10 months ago

Hello @ramsaym,

I believe the issue you're currently having is the CLI thinks that ..\gui_out\Dairy is a folder containing component folders to process. In it's current implementation, the -s flag will only move a given settings file into the farm folder generated by importing a .json file from the GUI (in this case, using the -i flag).

Even with input flags, the way the CLI is designed will necessarily assume any folder in your given directory represents a farm, and will try to process the data as such.

If you wish to use the input flags as you have, I recommend creating a new folder that contains only your exported .json file, and your desired .settings file, like this:

image

I will begin looking into implementation of a command flag for SLC polygon IDs.

ramsaym commented 10 months ago

Ok I was able to run the command line H.CLI from the /Debug folder. It did still ask me to input all the parameters I included in the command line so is there a way to suppress the prompts? I am getting data in the /Fields folder for the farm, but I am only getting zeros in the GHG and Co2e reports. I am hoping to generate several years of emissions estimates for C02, N20, and Ch4 (as Co2e)

ramsaym commented 10 months ago

One more thing, it seems as though only the Beef (Livestock components) are being included in the emissions reports as generated via the CLI command line

aaron-mcpherson commented 10 months ago

Ok I was able to run the command line H.CLI from the /Debug folder. It did still ask me to input all the parameters I included in the command line so is there a way to suppress the prompts? I am getting data in the /Fields folder for the farm, but I am only getting zeros in the GHG and Co2e reports. I am hoping to generate several years of emissions estimates for C02, N20, and Ch4 (as Co2e)

Hi @ramsaym , there is a new installer for the CLI, can you download the latest update to see if the issue is fixed for you?

ramsaym commented 10 months ago

Hey @aaron-mcpherson The command line now works and doesn't require me to re-enter any flags. I am processing farms through to completion but the emissions reports still aren't showing any crop GHGs, only the livestock ones?

ramsaym commented 10 months ago

@aaron-mcpherson Perhaps I missed it before but I now see two columns for C02 in the fields.csv report, which is ideally the report I'd like to export anyways. image image

If all the emissions can be captured by this .csv in fields I think I am up and running with a batch service script

holos-aafc commented 10 months ago

@aaron-mcpherson Perhaps I missed it before but I now see two columns for C02 in the fields.csv report, which is ideally the report I'd like to export anyways. image image

If all the emissions can be captured by this .csv in fields I think I am up and running with a batch service script

Hi @ramsaym , these two CO2 outputs are from energy use (emissions from machinery needed to spread fertilizer, and upstream CO2 emissions produced at the factory where the fertilizer is created).

These two columns do not represent the CO2 associated with the carbon in the soil.

To determine the amount of carbon sequestered in the soil, you would have to look the column labelled "Soil Carbon (C_t) (kg C ha^-1)" and decided on a period of time (start year and end year) in which you will compare the soil carbon at the start year with the soil carbon at the end year.

For example, if I choose a start year of 1985, and the "Soil Carbon (C_t) (kg C ha^-1)" column reports 50000 kg C / ha during this year and a soil carbon estimate of 60000 kg C / ha in the year 2000, then my total soil carbon content would be (60000 - 50000) = 10,000 kg C / ha in the year 2000. This soil carbon measurement can then be converted to CO2 equivalents.

This is partly why we don't include the field emissions in the same report as the animal emissions - it is more informative to see the emissions from the fields on a year by year basis.

Does this provide any clarification on the outputs for your scenario?

For reference the last two columns 'BZ' and 'CA' correspond to these two columns in the GUI output (tooltips captured):

sshot-151

sshot-152

ramsaym commented 10 months ago

Ok that works Aaron. As long as can capture all emissions with that file. So the Soil Carbon produced by plant respiration less the Carbon that is stored as soil carbon would then represent carbon lost as CO2 respiration? I want to make sure we capture green manure decomp and the ~85% of carbon that doesn't get retained as SOC

UrsakiUleth commented 10 months ago

Hello @ramsaym,

The new CLI installer is now available here: https://github.com/holos-aafc/Holos#download

The flag for SLC polygon ID is "-p". As requested, the given .json farm is processed with climate and geographic data is derived from the given polygon ID.

The command flag will NOT alter the .json file in any way.

Let me know if you have any problems or questions.

apologies on the delay. I would think it easiest to create a flag for the SLC polygon ID and derive the climate data from that. Does that work. Also, I am still getting a request to enter parameters even when I use the flags from the bin/DEbug folder

image

UrsakiUleth commented 10 months ago

Hello again @ramsaym ,

There is a new CLI installer available: https://github.com/holos-aafc/Holos#download

You can now use a flag "-f" followed by the name of your chosen folder to import multiple farms at once.

Like the input flags, the folder needs to be within the farms folder specified by the first command line argument.

Let me know if you have any questions.