CEMPD / SMOKE

Create emissions inputs for multiple air quality modeling systems with unmatched speed and flexibility
https://www.cmascenter.org/smoke/
45 stars 21 forks source link

SMOKE-AERMOD grid cell lat-lon coordinates are incorrect #40

Closed cseppan closed 2 years ago

cseppan commented 3 years ago

When running Smkreport with the AERMOD NONPOINT instruction, Smkreport will output the grid cell coordinates in lat-lon. These coordinates aren't matching what would be expected based on the Lambert coordinates and spheroid.

James Beidler will provide examples of correct inputs and outputs.

Here's the section of code that does the coordinate conversions:

https://github.com/CEMPD/SMOKE/blob/ffa9e3cb0356f2294845a903384fe5fca4c8973f/src/emqa/wrrepout.f#L815-L849

According to the IOAPI documentation, the XY2XY method should take the environment variable IOAPI_ISPH into account: https://www.cmascenter.org/ioapi/documentation/all_versions/html/XY2XY.html

I suggest creating a simple Fortran program that calls XY2XY to see what the output values are, using James' example data.

christos-e commented 2 years ago

Coded with alternative options found here but results remain the same:

https://www.cmascenter.org/ioapi/documentation/all_versions/html/SETSPHERE.html

cseppan commented 2 years ago

It looks like you need to explicitly call the function INITSPHERES() before using XY2XY(). This should read the environment variable and then XY2XY will automatically use the value. I'd suggest adding the call to smkreport.f, right after the existing initialization functions:

https://github.com/CEMPD/SMOKE/blob/f371a0fe153e04d7f64bda7099a260e21309df48/src/emqa/smkreport.f#L143-L151

christos-e commented 2 years ago

I added an IF THEN statement from /src/emmod/modgrdlib.f that seems to be doing that in wrrepout.f and fixes the issue.