Skip to content

Comments

[WIP] Expanded planted area#146

Draft
lukaszgajewski wants to merge 26 commits intoallfed:mainfrom
lukaszgajewski:expanded_planted_area
Draft

[WIP] Expanded planted area#146
lukaszgajewski wants to merge 26 commits intoallfed:mainfrom
lukaszgajewski:expanded_planted_area

Conversation

@lukaszgajewski
Copy link
Contributor

TODO

  • The raw input data is yet to be updated
  • Link to the paper is to be included (here, and probably somewhere in the docs)
  • Possibly a few more tests

Description

This PR implements expanded planted area as developed by Monteiro et al. (link pending)
It takes values calculated by Luisa – monthly increase in wheat yield – converts them to yearly values, and applies seasonality (per already existing data in the repository), and assigns zero to the first nine months.
Nine, because of the assumption in the paper: “that land cleared in a month is immediately cultivated, and wheat is harvested from that area 8 months after cultivation”.
We do not provide a parameter to control this because the 8 months is assumed throughout the model so we cannot just shift the zeroing out in the integrated model. In order for this to be customisable, we need a full extended planted area model implementation, and not just plugin the pre-computed results into the integrated model as this PR is doing.
These values are then added to the outdoor crop production values (OutdoorCrops.KCALS_GROWN and OutdoorCrops.NO_RELOCATION_KCALS_GROWN).
The addition is done after nuclear winter reduction since the values calculated by Luisa already include that reduction.
Note: as of right now we only have values for wheat.

Birds-eye view of the changes:

  • Removed:
    • all references to the all_resilient_foods_and_more_area scenario (including a test in tests/test_argentina_parameters.py).
    • assign_increase_from_increased_cultivated_area function from OutdoorCrops class.
    • expanded_area_and_relocated_outdoor_crops function from the Scenarios class.
    • get_all_resilient_foods_and_more_area_scenario function from the Scenarios class.
  • Added:
    • Description of the new yaml setting – expanded_area – in scenarios/README.md.
    • An example yaml using this new setting (USA_expanded.yaml).
    • assign_increase_from_expanded_planted_area function to the OutdoorCrops class.
    • data/no_food_trade/raw_data/luisa_expanded_planted_area.csv – data from Luisa Monteiro.
    • src/import_scripts_no_food_trade/create_expanded_area_csv.py script that takes a spreadsheet from Luisa Monteiro as an input and creates a CSV file formatted analogously to other “processed” CSV files in the repository.
    • The aforementioned CSV file: data/no_food_trade/processed_data/expanded_area.csv.
    • data/tests_data/outdoor_crops_constants_for_params_usa_extended_yaml.pickle for testing purposes.
    • set_expanded_area to the Scenarios class.
    • Tests:
      • Integration:
        • tests/test_expanded_area.py
        • tests/test_expanded_area_global.py
      • Unit:
        • tests/test_food_system_outdoor_crops.py
        • tests/test_scenario_loader.py
  • Modified:
    • Already existing yaml files, they now use the new expanded_area setting.
    • src/import_scripts_no_food_trade/import_food_data.py to include the expanded area csv
    • data/no_food_trade/computer_readable_combined.csv, as above
    • calculate_monthly_production function in OutdoorCrops class to call assign_increase_from_expanded_planted_area instead of expanded_area_and_relocated_outdoor_crops.
    • set_depending_on_option in ScenarioRunner; it now has additional assertions enforcing proper data types and calls set_expanded_area from the Scenarios class.

@lukaszgajewski
Copy link
Contributor Author

lukaszgajewski commented Sep 6, 2024

Ah, a slight oversight on my part -- the repo tests use Python 3.9 and I tested locally with 3.12, so for example the match statement is not available in 3.9.
Should we update the repo tests to use a newer Python version or should I stick with 3.9 in my implementation?

@simonblouin
Copy link
Collaborator

If don't have any problem with upgrading to 3.12. Also I think the environment.yml file should be more explicit about versions to avoid this kind of issue going forward.

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