OMS-NetZero / FAIR

Finite-amplitude Impulse Response simple climate model
https://docs.fairmodel.net
Apache License 2.0
125 stars 63 forks source link

fill_species_configs is erroring when aci type not defined #151

Closed chrisroadmap closed 7 months ago

chrisroadmap commented 7 months ago

these lines here may need an if function to check whether aci and ch4 are included before trying to fill them

https://github.com/OMS-NetZero/FAIR/blob/c09bee83c7f2c43a32f1978b15fb5cbbc5f5cf87/src/fair/fair.py#L717C1-L724C10

This arises when f.fill_species_configs(FILE) takes a CSV file as input and the ch4 or aci species types are not defined in the problem.

Raises this error:

ValueError: could not broadcast input array from shape (0,) into shape (1,)

chrisroadmap commented 7 months ago

that whole code block is re-factoring potential gold.

chrisroadmap commented 7 months ago

I can reproduce the error with the below (make a species_configs csv, delete all rows except ch4, so that aci not included)

from fair import FAIR
from fair.io import read_properties
f = FAIR()
f.define_time(2000, 2050, 1)
f.define_configs(["high", "central", "low"])
f.define_scenarios(["abrupt", "ramp"])
species, properties = read_properties('species_configs_properties_ch4.csv')
f.define_species(species, properties)
f.allocate()
f.fill_species_configs('species_configs_properties_ch4.csv')  # this line should fail

ValueError: could not broadcast input array from shape (0,) into shape (3,)