Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Hourofyear should have size 8784 #80

Open
efmkoene opened this issue Feb 25, 2025 · 2 comments
Open

[Bug]: Hourofyear should have size 8784 #80

efmkoene opened this issue Feb 25, 2025 · 2 comments

Comments

@efmkoene
Copy link
Contributor

Bug summary

The hourofyear NetCDF needs to have a fixed size of 8784 hours; which isn't the case currently (maybe it is for a leap year, but not for my tested year 2018).

Code for reproduction

from emiproc.inventories.tno import TNO_Inventory
inv = TNO_Inventory("/users/ekoene/CTDAS_inputs/TNO_6x6_GHGco_v4_0/TNO_GHGco_v4_0_year2018.nc")

from emiproc.grids import ICONGrid
icon_grid_file = "/users/ekoene/CTDAS_inputs/icon_europe_DOM01.nc"
icon_grid = ICONGrid(icon_grid_file)

# Convert to a planar crs before
# you will get a warning from pygeos if you dont do that
from emiproc.grids import WGS84_PROJECTED
inv.to_crs(WGS84_PROJECTED)

from emiproc.regrid import remap_inventory
remaped_tno = remap_inventory(inv, icon_grid, ".remap_tno5")

from emiproc.exports.icon import export_icon_oem, TemporalProfilesTypes
export_icon_oem(remaped_tno, 
                icon_grid_file, 
                "/capstor/scratch/cscs/ekoene/inventories/icon_with_tno_emissions/", 
                temporal_profiles_type=TemporalProfilesTypes.HOUR_OF_YEAR,
                year=2018,
                substances='CO2')

Additional information

Currently, in ICON-ART-OEM, the following things are hardcoded:

  INTEGER,  PARAMETER :: tp_param_hour = 8784
<...>
      ierror = nf90_get_var(hyid, varid, oem_data%tp_hourofyear(:,i,:), &
                            start = (/1,1/), count=(/oem_config%tp_ncountry,tp_param_hour/), &
                            map = (/ tp_param_hour, 1 /))

in other words, it tries to read out a table from (1,1) to (n_countries, 8784) from the NetCDF. However, emiproc only writes out a table of size (1,1) to (n_countries, 8760) for the TNO database for the year 2018. Hence, the NetCDF reading runs into an error as there isn't enough data present, and ICON crashes correspondingly.

I manually simply appended a copy of the final day into the NetCDF as a workaround for my case, but it'd be good if this could be addressed in emiproc in some way.

@lionel42
Copy link
Collaborator

Thanks @efmkoene ,

My issue is still that in a non leap year like 2018, there are 8760 hours, whereas there are 8784 hours only during leap years, thus I think the problem has to be addressed on the OEM side and not on the emiproc side.

Is that so difficult to change in OEM ?

@efmkoene
Copy link
Contributor Author

That's fair. Let me check. :-)

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

No branches or pull requests

2 participants