Saving to Netcdf file and Latitude, longitude values

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
gdmontoyag
Posts: 5
Joined: Thu May 12, 2016 4:50 pm

Saving to Netcdf file and Latitude, longitude values

Post by gdmontoyag »

Dear User
Following the code suggested by Bob Carp in: viewtopic.php?f=31&t=1615 , I exported a satellite image to Netcdf, through the function exportGridToNetcdf (attached script: ImaToNetcdf0V_0.py). However, the written file Ir_Last.nc (attached) associated with the image, does not contain the latitude longitude values, in geographical coordinates (i.e., degrees). I saw this, typing the command: ncdump Ir_Last.nc.
Furthermore, I want to process the image with NCL (NCAR Command Language). My question is: how can I get these values?. Is there a way to export the 2-D lat/lon arrays?. A similar question was posted in the link: https://www.unidata.ucar.edu/support/he ... 04278.html

Any help is greatly appreciated. Thanks, Gerardo Montoya, National University of Colombia
Attachments
Ir_Last.zip
The output Netcdf file (compressed)
(1.49 MiB) Downloaded 321 times
ImaToNecdf0V_0.py
The script
(525 Bytes) Downloaded 330 times
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: Saving to Netcdf file and Latitude, longitude values

Post by jayh »

Hello Gerardo-

I talked with some colleagues here and we were wondering if you tried the Grid Table approach that was suggested in the Unidata forum thread you referenced? After displaying the Grid Table, you can use Ctrl-A to highlight the data, then copy and paste into Excel or another program that you could create a CSV file with the lat/lon values.

Currently there is not a way to get the lat/lon arrays in netCDF format. I have written that as a feature request in inq. 2389.

If you have any further questions, just let us know.

Thanks, Jay
McIDAS User Services
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: Saving to Netcdf file and Latitude, longitude values

Post by joleenf »

Hi Geraldo,

There is no easy way through the GUI, but the Advanced Scripting Tutorial: http://www.ssec.wisc.edu/mcidas/software/v/docs/UserFunctions1.5_v2.pdf outlines how to extract lat/lon values from a satellite image. If you feel comfortable writing code, you could use this and either

1.) write a CDM file and use "ncgen" to generate a netCDF file
2.) use the unidata java tools to write a netCDF (not as easy in my opinion but possible).

I agree, it would be a big help to get the lat/lon pairs plus data values in a netCDF from a McIDAS display via the GUI as long as the extraction of that image subset is data object based rather than some strange image conversion to a new data object.

Joleen
User avatar
gdmontoyag
Posts: 5
Joined: Thu May 12, 2016 4:50 pm

Re: I solved the question

Post by gdmontoyag »

Thanks to McIDAS users. I solved the question, writting 3 netcdf files. the script is attached. Thanks newly.
Attachments
Ir_imageTo_Netcdf.py
(1.49 KiB) Downloaded 359 times
Post Reply