Some questions about Polar2Grid

davidh
Posts: 116
Joined: Tue Jun 04, 2013 11:19 am

Re: Some questions about Polar2Grid

Post by davidh »

Dmitry,

To perform the equivalent for MODIS try these commands:

Code: Select all

source polar2grid_v_2_0/bin/polar2grid_env.sh
polar2grid_v_2_0/ShellB3/bin/python -m polar2grid.glue crefl hdf5 ... -p modis_crefl01_1000m modis_crefl02_1000m modis_crefl03_1000m modis_crefl04_1000m modis_crefl05_1000m modis_crefl06_1000m modis_crefl07_1000m
polar2grid_v_2_0/ShellB3/bin/python -m polar2grid.glue modis hdf5 ... -p bt20 bt21
For MODIS L1B we currently only have P2G configured for the bands listed on this page: http://www.ssec.wisc.edu/software/polar ... modis.html
Similarly if you wanted higher resolution crefl reflectance bands you can find the names of those products here: http://www.ssec.wisc.edu/software/polar ... crefl.html

Dave
Dmitry
Posts: 34
Joined: Mon Feb 29, 2016 3:56 am

Re: Some questions about Polar2Grid

Post by Dmitry »

Dear Dave,

Thanks a lot for your help and fast support.
Dave, please could you say me what is the precision of the rectified VIIRS, AVHRR and MODIS data via polar2grid?
What parameters are taken into account during the rectification process? Only the TLE file? or other additional parameters too?

Best regards,
Dmitry
davidh
Posts: 116
Joined: Tue Jun 04, 2013 11:19 am

Re: Some questions about Polar2Grid

Post by davidh »

Hi Dmitry,

I'm assuming by rectified you mean the precision of the resampling/remapping process? I don't fully understand the math involved in the algorithm, but I can tell you what I do know.

The default resampling for Polar2Grid uses an EWA algorithm which stands for "Elliptical Weighted Averaging" and consists of two steps. The code for this resampling was originally based on the "ms2gt" software created by the NSIDC (https://nsidc.org/data/modis/ms2gt/index.html). It was rewritten to work better with python, but the overall algorithm is still the same. The first step is called "ll2cr" which stands for "lat/lon to col/row". In Polar2Grid this uses PROJ.4 (via the python library pyproj) to navigate each longitude/latitude pixel to a cell on the output grid. The second step called "fornav" for "forward navigation" is where the actual EWA algorithm is performed. This algorithm operates on one scan line at a time (the whole swath for AVHRR) and calculates some coefficients and weights based on the location of each pixel in the scan. It then looks through each input swath pixel, applies the pixel to each output grid cell around it (in an ellipse), applying a weight based on how far the grid cell is from the swath pixel. Each grid cell will have the sum of the input pixels that affect it and the sum of the weights applied to those values. It can then perform the average "output = input_sum / weight_sum".

So the parameters involved are the longitude and latitude of each input pixel, the actual swath data, and the number of input data rows making up one scan line (whole swath for AVHRR). TLE files are not used. The EWA algorithm does allow you to control some of the coefficients (effect radius of each input pixel, etc), but P2G's defaults were chosen to produce the best results so you probably don't need to change these.

That might not be the answer you were looking for, but I hope it helps.

Dave
Dmitry
Posts: 34
Joined: Mon Feb 29, 2016 3:56 am

Re: Some questions about Polar2Grid

Post by Dmitry »

Dear Dave,

Thanks a lot once again for your support and the provided data.

I question has arisen. For example, I have an AAPP avhrr l1b file which includes data from the Equator to the North Pole, nevertheless I need an specific area for my work. Is it possible to automatically process the area I am interested in without processing the rest of the image by using polar2grid?

Thanks beforehand.

Best regards,
Dmitry
davidh
Posts: 116
Joined: Tue Jun 04, 2013 11:19 am

Re: Some questions about Polar2Grid

Post by davidh »

Hi Dmitry,

It is sort of possible. Polar2Grid will have to load in the entire swath and start the remapping process before it figures out what part of the swath is important. You can specify your own custom grid to cover a certain area, see the instructions in the installation guide provided with Polar2Grid. In the future we plan on subsetting the data earlier in the process, but this functionality isn't ready yet.

Dave
Dmitry
Posts: 34
Joined: Mon Feb 29, 2016 3:56 am

Re: Some questions about Polar2Grid

Post by Dmitry »

Dear Dave,

Thanks a lot for your answer, I just had enough time to study that issue.

I created our own grid (belarus_grid) using p2g_grid_helper.sh. Here you have its parameters:
belarus_grid, proj4, +proj=lcc +datum=WGS84 +ellps=WGS84 +lat_0=27.603 +lat_1=27.603 +lon_0=53.920 +units=m +no_defs, 1000, 1000, 1100.000, -1100.000, 48.090deg, 32.442deg

I have a questions:
1.After applying the belarus_grid I get a file with lcc projection, and I need that for belarus_grid the projection was latlong. Is it possible to get it in latlong projection? How to do it?
2.What happens with the part non-pertaining to belarus_grid (for example, noaa l1b) after processing? Is it cutted by latitude and longitude?
3.What happens with the file (for example, noaa l1b), which is fully non-part of belarus_grid? I suppose it should not be processed, is it correct?

Best regards,
Dmitry
davidh
Posts: 116
Joined: Tue Jun 04, 2013 11:19 am

Re: Some questions about Polar2Grid

Post by davidh »

Hi Dmitry,

1. If you would like a different projection you can specify the PROJ.4 string using the "-p" flag. Make sure to wrap your projection string in quotes like this:

p2g_grid_helper.sh -p "+proj=latlong +datum=WGS84 +ellps=WGS84" ...

2. and 3. I'm not sure I understand the difference between these 2 questions. When you call a p2g "glue" script like avhrr2gtiff.sh you provide a series of files and optionally what products you want ("band1", "band2", etc). Polar2Grid will load all of the data for the corresponding bands from the files you provide. It then attempts to remap that data to one or more grids that you specify. Once the output grid is filled in with data then this is the only data that gets processed/written to the output file. This means if you provide much more data than what pertains to your grid, P2G still has to load ALL of your data in to memory to know what pertains to the grid (how would it know otherwise).

The data being remapped is not necessarily "cut by latitude and longitude", but is interpolated (with an elliptical weighted averaging algorithm) to produce the best resulting image. If an input swath pixel is "too far away" from the output grid's location then it is simply discarded from further processing and from the interpolation algorithm.

I hope this helps explain what's going on a little more.
Dave
Dmitry
Posts: 34
Joined: Mon Feb 29, 2016 3:56 am

Re: Some questions about Polar2Grid

Post by Dmitry »

Dear Dave,

Must my writing look like this?

./p2g_grid_helper.sh -p "+proj=latlong +datum=WGS84 +ellps=WGS84" belarus_grid 27.603 53.920 1100 1100 1000 1000
then I get
belarus_grid, proj4, +proj=latlong +datum=WGS84 +ellps=WGS84, 1000, 1000, 1100.000, -1100.000, -549972.397deg, 550053.920deg
- this result confuse me

or I need to convert the highlighted magnitudes to degrees?

I understand the rest of questions.

Regards,
Dmitry
davidh
Posts: 116
Joined: Tue Jun 04, 2013 11:19 am

Re: Some questions about Polar2Grid

Post by davidh »

Yes you must specify your pixel sizes in degrees. There is no concept of meters in a latlong grid (the other projections are used for that). If you need a cylindrical projection in meters you could try mercator "merc".
Dmitry
Posts: 34
Joined: Mon Feb 29, 2016 3:56 am

Re: Some questions about Polar2Grid

Post by Dmitry »

Dear Dave,

Thank you for your answer, I got it.

Something else:

During processing I often get this message:

/home/IPOPP/Downloads/polar2grid_v_2_0/ShellB3/lib/python2.7/site-packages/polar2grid.avhrr-1.0.0-py2.7.egg/polar2grid/avhrr/readers.py:371: RuntimeWarning: divide by zero encountered in divide
numpy.log(1 + ir_const_1 cwnum cwnum * cwnum / rad)

and after it:
ERROR : Remapping error
ERROR : Remapping data failed

I housed samples of those files at:
https://drive.google.com/open?id=0B-QeK ... kZHOGJaT0E

Please could you say what is wrong?

Best regards,
Dmitry
Post Reply