os-climate / hazard

Onboarding, creation and transformation of climate hazard models for OS-Climate
Apache License 2.0
8 stars 12 forks source link

Expanded model resource #121

Closed ciaransweet closed 2 months ago

ciaransweet commented 2 months ago

Probably one for @joemoorhouse

Could you possibly give me an example/point me to where I would call expand() on a hazard resource to get its fully templated out values?

For example, right now we have: https://github.com/os-climate/hazard/blob/main/src/hazard/services.py#L61

But I get values like:

            "path": "chronic_heat/osc/v2/days_tas_above_{temp_c}c_{gcm}_{scenario}_{year}",
            "indicator_id": "days_tas/above/{temp_c}c",
            "indicator_model_id": null,
            "indicator_model_gcm": "{gcm}",

In the inventory.json output

In that line of code linked, which spot is the appropriate place to .expand() the resource?

ciaransweet commented 2 months ago

Or perhaps it doesn't make sense to expand for inventory? But I suppose for STAC it does? As we have individual entries for each combination of parameters?

Edit: Okay actually I think I understand better now, inventory.json somewhat describes all the possible combinations. For the case of STAC, we still have the case where values aren't really templated out but I think that's due to the STAC implementation naively just dumping all values, rather than templating out the combinations.

joemoorhouse commented 2 months ago

Hi @ciaransweet, Yes that's right. It's templated in inventory.json and only expanded at the point where inventory.json is converted back into HazardResource objects (e.g. in physrisk). This is done to keep inventory.json smaller and more maintainable. I think main examples are when there are multiple GCMs used or in the case of work loss when there are different categories of activity. Arguably, GCM is such a common use case that it could be made a first-class citizen together with scenarios and years...