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

Create new Nuiqsut data inputs #135

Closed
rarutter opened this issue Sep 28, 2015 · 7 comments
Closed

Create new Nuiqsut data inputs #135

rarutter opened this issue Sep 28, 2015 · 7 comments

Comments

@rarutter
Copy link
Collaborator

For this we need an initial point to start from (in lat/lon).

@tobeycarman
Copy link
Member

My process for finding/creating the Toolik inputs is enumerated below. I bet there are a bunch of easier ways to do this, especially if you are versed with some kind of GIS program.

  1. find lat/lon for Toolik (I can't remember if I asked Colin, or used values I found from the website for Toolik research station)
  2. translate one of the SNAP input files from .tif to .netcdf. The reason being that the SNAP .tif files are geo-referenced, but I wasn't sure how to get the lat/lon for a given pixel out of a .tif file. Also the .tif is projected, so the lat/lon to not vary linearly from pixel to pixel, so you can't find a pixel that is close and then just extrapolate from there. Here is the command to do the translation:

    $ gdal_translate -co WRITE_LONLAT=YES -of netcdf ../snap-data/tas_mean_C_iem_cccma_cgcm3_1_sresa1b_2001_2100/tas_mean_C_iem_cccma_cgcm3_1_sresa1b_01_2001.tif temporary.nc Input file size is 2560, 1850 0...10...20...30...40...50...60...70...80...90...100 - done.

  3. Then it gets a little tedious. Open the temporary.nc file with ncview, and display the lat variable:
    step2
  4. Then use the magnifier button (right under the 'pause': e.g. M 1/3) to zoom way way in and move around till I find the pixel that has the closest latitude to the target. Note the offset (i and j) values for the pixel
  5. Repeat for Longitude
  6. use the best (i,j) values as offsets to pass into our scripts/create_region_inputs.py script. I setup the Toolik sample data so that Toolik is the lower left corner of the input domain, (0,0).

@tobeycarman
Copy link
Member

OK, I checked out and older version (before we deleted the old-style sample input data) and checked for the lat/lon that were used there:

$  git checkout 752b78bd
...detached head state, blah, blah...
$  ncdump DATA/Nuiqsut_Inputs/datagrid/grid.nc
((752b78b...))$ ncdump DATA/Nuiqsut_Inputs/datagrid/grid.nc 
netcdf grid {
dimensions:
    GRIDID = UNLIMITED ; // (1 currently)
variables:
    double LAT ;
        LAT:missing_value = -9999.f ;
    double LON ;
        LON:missing_value = -9999.f ;
    int GRIDID(GRIDID) ;
        GRIDID:long_name = "GRIDID" ;
    int DRAINAGEID(GRIDID) ;
    int SOILID(GRIDID) ;
    int GFIREID(GRIDID) ;
data:

 LAT = 70.1789 ;

 LON = -151.0077 ;

 GRIDID = 1 ;

 DRAINAGEID = 1 ;

 SOILID = 195 ;

 GFIREID = 195 ;
}

Will check to see if this makes sense in light of the new inputs.

@tobeycarman
Copy link
Member

This link has the super slick way(s) to look up pixel location based on Lat/Lon:
http://nbviewer.ipython.org/github/Unidata/tds-python-workshop/blob/master/netcdf-by-coordinates.ipynb

@tobeycarman
Copy link
Member

Using all methods above (manual using ncview, euclidean distance, and tunnel distance), I come up with pixel coordinates (1725, 850), (iy,ix), as the best/closest pixel to the pixel used in the old Nuiqsut data set.

In [55]:  !gdal_translate -of netcdf -co WRITE_LONLAT=YES ../snap-data/iem_ancillary_data/Landcover/LandCover_iem_TEM_2005.tif temp-veg.nc
Input file size is 2560, 1850
0...10...20...30...40...50...60...70...80...90...100 - done.

In [56]: ds = netCDF4.Dataset("temp-veg.nc", 'r')

# copied 'tunnel_fast' function from the Unidata IPython Notebook linked above
In [57]: tunnel_fast(ds.variables['lat'], ds.variables['lon'], 70.1789,-151.0077)
Out[57]: (1725, 850)

In [58]: ds.variables['lon'][1725,850]
Out[58]: -151.00816

In [59]: ds.variables['lat'][1725,850]
Out[59]: 70.177719

@tobeycarman
Copy link
Member

Very possible that the slight difference in lat/lon coordinates has to do with which part of the pixel is referenced (one of the corners, or the center). I have not been able to figure out what is used by default with the gdal command line utils.

@rarutter
Copy link
Collaborator Author

Just talked to Michael about gdal utilities, and he says it's probably the upper left of the pixel. He provided a snippet of code here:
https://github.com/EarthScientist/etc/blob/master/centroid_from_raster.py
for calculating the centroids if that's what we want.

@rarutter
Copy link
Collaborator Author

This issue is no longer relevant. I linked to it from the wiki page on input generation for ease of locating details.

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