Skip to content

Potential issue in matching model grids and inventory sites when coordinates in different format #1457

@XiulinGao

Description

@XiulinGao

if ( sqrt( (sites(s)%lat-inv_lat_list(invsite))**2.0_r8 + &
(sites(s)%lon-inv_lon_list(invsite))**2.0_r8 ) > max_site_adjacency_deg ) then

I was running a regional FATES initialization using inventory data from a bunch of different sites. The customized model grids have the longitudes in [-180,180] degree format, which is same as the coordinates formate of the inventory sites. Also, inventory sites were mapped to model grids before hand, thus the latitude and longitude columns in the control file corresponds to exact target model grid, so we would not expect model fail due to model cannot find the closest inventory site within allowed precision. I still run into the issue, which later I discovered that at line 620, model converted negative longitudes of inventory sites to positive, this then made a mismatch between model grids and inventory sites in their coordinates format, and lines 239-240 are fragile to this format mismatch.

if( site_lon<0.0_r8 ) site_lon = 360.0_r8 + site_lon

One suggestion to fix this is to change the calculation of the distance between model grid and inventory grid in lines 239-240 to something like: dlon = abs( modulo(site_lon - inv_lon(:) + 180._r8, 360._r8) - 180._r8 ); distance = sqrt((site_lat - inv_lat)2 + dlon2). In this way, the calculation of dlon does not depend on exact same format between site and model grid coordinates as it's always computing the circular difference.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    ❕Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions