Re: create and extract Lat lon variables netcdf data

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 23 2013 - 10:44:18 MDT

It looks like the xpixel and ypixel are associated with lat and lon,
and not lon and lat like I thought.

If you look at the output from the "printMinMax" statements, it
reports:

(0) x pixel: min=0 max=1792
(0) y pixel: min=0 max=3257
(0) latitude: min=-13.49 max=8
(0) longitude: min=92.5 max=143.99

On the file, the Lat/Lon dimensions are indicated to be:

    dimensions:
       Lat = 2150
       Lon = 5150

Since the max Y pixel is 3257, this is too large to be a latitude
index, so my guess is that Y pixels are associated with Lon, and X
pixels with Lat.

You will likely need to fix the original script I sent you, and the
new one, to switch the xpixel and ypixel references.

That is, change:

         sprintf("%7.3f",lat(ypixel)) + " " + \
         sprintf("%7.3f",lon(xpixel)) + " " + \

to:

         sprintf("%7.3f",lat(xpixel)) + " " + \
         sprintf("%7.3f",lon(ypixel)) + " " + \

Your do loop looks correct, so I don't think you need to fix this:

   qpe2d = new((/nlat,nlon/),typeof(qpe1d))
   do n=0,npixel-1
     qpe2d(xpixel(n),ypixel(n)) = qpe1d(n)
   end do

--Mary

On Tue, 23 Apr 2013 02:11:03 -0700 (PDT)
  fatkhuroyan - <izzaroyan@yahoo.com> wrote:
> Hi Mary,
>
> Yes, I have modified your script, It start from left top of the file
>so I use : lat = a@Latitude  - ispan(0,nlat-1,1)*a@LatGridSpacing. 
>I also change line 64 to be : qpe2d(xpixel(n),ypixel(n)) = qpe1d(n).
> It corresponds to the radar picture  and It work for other CrefQC
>file for other regions but when i try to use the script for
>extracting qpe file,
>
> It is still error : fatal:Subscript out of range, error in subscript
>#0
> fatal:An error occurred reading lat
> fatal:["Execute.c":7556]:Execute: Error occurred at or near line 55
>in file read_QPE_topleft.ncl ".
>
> Actually, the qpe netcdf file is same as the CrefQC netcdf file, but
>there is still error for qpe file even after I try to
> modify the script.
>
> Here I attach the QPE' script and file.
>
>
> Thanks,
> --Royan
>
>
>
> ________________________________
> From: Mary Haley <haley@ucar.edu>
> To: fatkhuroyan - <izzaroyan@yahoo.com>
> Cc: "ncl-talk@ucar.edu" <ncl-talk@ucar.edu>
> Sent: Tuesday, April 23, 2013 3:57 AM
> Subject: Re: create and extract Lat lon variables netcdf
>data
>
>
> Royan,
>
> You will likely need to modify your file to handle other data files,
>because I hard-coded some values to handle the file you gave me.
>
>For example, I set:
>
> ;---Construct lat/lon arrays
>   nlat = 935
>   nlon = 940
>   lat = a@Latitude  + ispan(0,nlat-1,1)*a@LatGridSpacing
>   lon = a@Longitude + ispan(0,nlon-1,1)*a@LonGridSpacing
>   lat@units = "degrees_north"
>   lat@units = "degrees_east"
>
> I probably should have used this:
>
>   file_dimsizes = getfiledimsizes(a)
>   nlat = a(0)
>   nlon = a(1)
>   lat = a@Latitude  + ispan(0,nlat-1,1)*a@LatGridSpacing
>   lon = a@Longitude + ispan(0,nlon-1,1)*a@LonGridSpacing
>   lat@units = "degrees_north"
>   lat@units = "degrees_east"
>
> The assumption here is that "getfiledimsizes" returns the latitude
>dimension size first, then the longitude one.
>
> If the Latitude and Longitude attributes on the file mean that you
>have to start from the left top of the file, then you
> simply need to change your latitudes to be:
>
>   lat = a@Latitude  - ispan(0,nlat-1,1)*a@LatGridSpacing
>
> As for your question "Can I overlay the .nc file on a map ", the
>script I sent you did that. I included a picture too.
> Did you not get these attachments? I sent the email on April 15. I
>will include a modified version of that
> script that assumes that the
> Latitude/Longitude mean the top left of the plot.
>
> Please study this script closely before you modify it to work with
>other files. Also, make sure that the
> lat/lon arrays I generated are correct.
>
> --Mary
>
>
>
>
> On Apr 16, 2013, at 3:05 AM, fatkhuroyan - wrote:
>
>> Hi Mary,
>>
>> Thanks for your explanation, but I try to open other file for other
>>region but there were error message :
>> " fatal:Subscript out of range, error in subscript #0
>> fatal:An error occurred reading lon
>> fatal:["Execute.c":7556]:Execute: Error occurred at or near line 57
>>in file read_CrefQC.ncl "
>>
>> Here I send the .png picture  as reference to construct the lat/lon
>>array then I want to extract .nc file according to that picture to
>>open the file, read off the pixel data and the data values, and print
>>them out in Lat Lon, dBz values.
>>
>> Maybe, the Information from the file :
>>                  :DataType = "SparseLatLonGrid" ;
>>                :Latitude = 7.874167 ;
>>                :Longitude = 93.14028 ;
>>                :LatGridSpacing = 0.005 ;
>>                :LonGridSpacing = 0.005 ;
>> It mean that the Lat : 7.874167 and Lon : 93.14028 as the start
>>point from the left top of the picture to construct the Lat/lon
>>arrays.
>>
>> Once more, Can I overlay the .nc file on a map ? or add a map in the
>>.nc file when i want to display that .nc file ?
>>
>> Thanks,
>> Royan
>>
>>
>>
>>
>>
>> From: Mary Haley <haley@ucar.edu>
>> To: fatkhuroyan - <izzaroyan@yahoo.com>
>> Cc: "ncl-talk@ucar.edu" <ncl-talk@ucar.edu>
>> Sent: Tuesday, April 16, 2013 6:02 AM
>> Subject: Re: create and extract Lat lon variables netcdf
>>data
>>
>> Hi Royan,
>>
>> We suggest new users of NCL look at this page:
>>
>> http://www.ncl.ucar.edu/get_started.shtml
>>
>> and in particular the "Mini Reference Manual":
>>
>> http://www.ncl.ucar.edu/Document/Manuals/language_man.pdf
>>
>> Meanwhile, if I understand your question, you simply want to open
>>the file, read off the pixel data and the data values, and print them
>>out?
>>
>> I tried reading your data, but there were some issues with it.
>>
>> First, a simple "ncdump" on the file indicates a missing value for
>>the "SingleLayerCRefQC" array:
>>
>>                :MissingData = -99900.f ;
>>
>> but when I tried to use this, I found values in your variable equal
>>to -99903, which also seems like a missing value.
>> So, I used -99903 instead of -99900.
>>
>> Secondly, it's not clear to me how to construct your lat/lon arrays.
>>There is this information on your file:
>>
>>                :DataType = "SparseLatLonGrid" ;
>>   
>             :Latitude = 7.874167 ;
>>                :Longitude = 93.14028 ;
>>                :LatGridSpacing = 0.005 ;
>>                :LonGridSpacing = 0.005 ;
>>
>> But I'm not sure what the "Latitude" and "Longitude" attributes on
>>the file mean.
>>
>> Also, I see these dimension names:
>>
>>    dimensions:
>>      Lat = 935
>>      Lon = 940
>>      pixel = 70111
>>
>> Here, I assume that "Lat" and "Lon" indicate the dimensions of a
>>two-dimensional array?
>>
>> You will have to provide more information about how the lat/lon
>>arrays are supposed to be constructed.  Maybe you can use something
>>like:
>>
>>    lat = a@Latitude + ispan(0,934,1)*a@LatGridSpacing
>>    lon = a@Longitude + ispan(0,939,1)*a@LonGridSpacing
>>
>> But again, I don't know how this ties into your pixel locations.
>>
>> I took a stab at guessing how the lat/lon arrays are supposed to be
>>constructed, and even tried recreating the 2D sparse array to see
>>what a plot looks like.
>>
>> See attached image and script. You will need to look over the
>>construction of the lat/lon arrays carefully, if the information
>>doesn't look correct. In particular, you will need to fix these
>>lines:
>>
>> ;---Construct lat/lon arrays                   
>                                
>>  nlat = 935
>>  nlon = 940
>>  lat = a@Latitude  + ispan(0,nlat-1,1)*a@LatGridSpacing
>>  lon = a@Longitude + ispan(0,nlon-1,1)*a@LonGridSpacing
>>
>>
>> Also, I don't know for certain what xpixel and ypixel correspond to,
>>so you may need to fix these lines as well:
>>
>>  dbz2d = new((/nlat,nlon/),typeof(dbz1d))
>>  do n=0,npixel-1
>>    dbz2d(ypixel(n),xpixel(n)) = dbz1d(n)
>>  end do
>>
>> --Mary
>>
>> <CrefQC_plot.png>
>>
>> On Apr 15, 2013, at 3:28 AM, fatkhuroyan - wrote:
>>
>>> Hi all,
>>>
>>> Iam newbie in ncl and i have been searching far but  i couldn't find
>>>!
>>> could someone help me how to manage and to extract lon lat variable
>>>(dbz) so I know that i coud work out manually which pixels correspond
>>>to which location and its reflectivity value ? ( I want to make and 
>>>extract in :  Lat-Lon-dbz value).
>>>
>>> Here I attach the files
>>>
>>> Thanks,
>>> Royan
>>> <CrefQC.nc>_______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>>
> <zoomBlueMarble_20130414_0008.png><20130414-000817.netcdf>
Received on Tue Apr 23 10:44:20 2013

This archive was generated by hypermail 2.1.8 : Tue Apr 23 2013 - 12:54:13 MDT