Running InMAP with netCDF Emission Files

87 views
Skip to first unread message

Ana Carolina Godoy Albino

unread,
Jun 20, 2024, 5:26:15 PM6/20/24
to inmap-users

Hello everyone,

I am currently working on a project where I need to integrate emission files in netCDF format into InMAP. I would like to know if any of you have had experience with this integration and if you could kindly share the command script used.

Any help or guidance will be greatly appreciated, thank you in advance for your assistance!

Ana Carolina 

Aaron Watt

unread,
Jun 21, 2024, 12:56:47 PM6/21/24
to inmap-users
Hi Ana!

From what I understand, InMAP only takes emissions input as shapefiles. The needed shapefiles contain emissions, latitude, longitude, and potentially release-point characteristics of emissions, for one point in time. NetCDF files potentially contain 3-D (latitude, longitude, time or latitude, longitude, altitude) or 4-D (latitude, longitude, altitude, time). Can you describe the axes/format of your netCDF file? And is the data based on average emissions in geographic gridcells or emission points?

You'll likely need to take two steps:
  1. decide which slice of data you want to run inmap simulations on: which time or altitude in your netCDF do you want to use?
  2. extract that slice of your netCDF into a shapefile.
For step 2, what programming language are you hoping to use for extraction? If you are comfortable with python, you can likely use the netCDF4, shapely, and geopandas packages to extract the data you need. I'm attaching an example python script of extracting data from netCDF and saving it in shapefile format. PS: chatGPT-4o is of great help with these types of questions and can probably guide you through the whole netCDF extraction process if you need some help with the python code.

Disclaimer: I'm a moderately active user of InMAP, but not a developer, so I may not be aware of other NetCDF functionality.
netcdf_to_shapefile_example.py

Aaron Watt

unread,
Jun 21, 2024, 1:04:55 PM6/21/24
to inmap-users
Also, if you have not seen it already, this blog post shows an example of the information needed in the emissions shapefile and how to construct it from outside data. 

Chris Tessum

unread,
Jun 21, 2024, 2:38:43 PM6/21/24
to inmap-users
Here is some information about how to use NetCDF emissions: https://inmap.run/docs/emissions/#coards-formatted-emissions . Basically, they have to be formatted in a certain way, and then you just set up the configuration file to use them.

Chris

Ana Carolina Godoy Albino

unread,
Jun 24, 2024, 4:37:57 PM6/24/24
to inmap-users

Hello Cris, 

Thank you for providing this link about the netCDFs. I am still having issues with this error. This happens because in my command script I only put a # before the section "EmissionsShapefiles = []" and inMAP tries to pull the following file: "["${INMAP_ROOT_DIR}/cmd/inmap/testdata/testEmis.shp"]." If I continue the configuration and run it this way, it gives the following error: "Error: there was a problem reading the emissions shapefile '/cmd/inmap/testdata/testEmis' The error message was open /cmd/inmap/testdata/testEmis.shp: The system cannot find the specified path. ← there was a problem reading the emissions shapefile '/cmd/inmap/testdata/testEmis' The error message was open /cmd/inmap/testdata/testEmis.shp: The system cannot find the specified path." If I remove the section "EmissionsShapefiles = []" inMAP turns the file dialog box red, indicating an error.

I manually removed the file "["${INMAP_ROOT_DIR}/cmd/inmap/testdata/testEmis.shp"]." and then got the following error: "Error: InMAP: problem initializing model: aep: opening GridRef file: open null: The system cannot find the specified file."

Could I be configuring something wrong? I will also share my command script, in case you don't mind taking a look.

Thank you in advance,

inmapModified_Ana_Transport_EDGAR_netCDF.toml

Ana Carolina Godoy Albino

unread,
Jun 29, 2024, 7:07:50 PM6/29/24
to inmap-users
I have updates regarding my attempt to use netCDF with inMAP. I created a reference grid to use in the spatialization of my netCDFs, but I still encountered an error displaying the following message:

"http: panic serving 127.0.0.1:52161: runtime error: index out of range [1] with length 1 goroutine 13 [running]:"

I understand that there is a problem with out-of-bound indexing when trying to access an element in a list or array. Specifically, the "index out of range [1] with length 1" error indicates that the code is trying to access the second element of an array which only contains one element. This has brought me back to square one, as I am unsure of how to resolve this issue.

I hope you can help me, thanks in advance,
Ana

Aaron Watt

unread,
Jul 1, 2024, 3:06:12 PM7/1/24
to inmap-users
Hello Ana,

Can you provide some information about the structure of your netCDF and a screenshot/copy of the full error message with the the inmap output? It might help to see what printed before the error occurred.

Ana Carolina Godoy Albino

unread,
Jul 1, 2024, 4:52:29 PM7/1/24
to inmap-users
Hi Aaron, sure, 

The emission file is a file downloaded from the EDGAR website (https://edgar.jrc.ec.europa.eu/). It contains data on latitude, longitude, and emission flux. The reference grid was created by anthro emiss, which I will also attach here. All the netCDF structure files and the InMAP error files have been placed in .txt files because they are too large to include in this conversation!

Structure - Grid File.txt
InMAP error.txt
Structure - Emission File.txt

Aaron Watt

unread,
Jul 8, 2024, 2:06:31 PM7/8/24
to inmap-users
Thanks for the output files! I've seen the "index out of range" error before when attempting to use a grid that is outside the bounds of the meterology file being used. Maybe this is the case here? If you can answer the following questions, it might help rule out if there is a mismatch in the grid and meterology.

1. From the InMAP error file, I can see the full inmap command given with flags. From the command flags used, it looks like you are using the inmap grid file named "global_inmap_004x003_v1.1.0.gob". I assume you create that grid file using a previous `inmap grid` command, is that right? 

2. If you used the inmap grid command, are the VarGrid flags in the InMAP error file you attached the same as the VarGrid flags used to create the grid file?

These are the VarGrid parameters given in the command:
--VarGrid.GridProj="+proj=longlat +units=degrees"
--VarGrid.VariableGridDx="2.5"
--VarGrid.VariableGridDy="2"
--VarGrid.VariableGridXo="-180"
--VarGrid.VariableGridYo="-88"
--VarGrid.Xnests="[143,2,2,2,2,2,2]"
--VarGrid.Ynests="[88,2,2,2,2,2,2]"

If those are the parameters used to generate the "global_inmap_004x003_v1.1.0.gob" file, then this grid covers nearly the entire globe. 

3. The command flags show the InMAPData meterology file to be "C:/Giusti-InMAP/EvaluationData_v1.1.0/EvaluationData_v1.1.0/InMAPData_v1.0.0.ncf". Did you create this file? If so, does it cover the entire globe?



Reply all
Reply to author
Forward
0 new messages