Re: create and extract Lat lon variables netcdf data

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 22 2013 - 14:57:26 MDT

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>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

CrefQC_plot_topleft.png
Received on Mon Apr 22 14:57:37 2013

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