Re: ncl-talk Digest, Vol 115, Issue 9

From: Feng Kong <kongfeng0824_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 04 2013 - 21:42:36 MDT

hi,
How are you?
I am writting to inquire how to read calipso data.Because the example in web is nc form. But my data is hdf form.
I do not know how to read.
Is there any example?
Thank you!


Feng


------------------
 孔锋
 单位:北京师范大学
         民政部/教育部减灾与应急管理研究院
        地表过程与资源生态国家重点实验室
 地址:中国北京市海淀区新街口外大街19号
 邮编:100875
 邮箱:kongfeng0824@qq.com kongfeng0824@gmail.com kongfeng0824@mail.bnu.edu.cn kongfeng0824@126.com
 …………………………………………………………………………………………………………………………………
Feng KONG

  State Key Laboratory of Earth Surface Processes and Resource Ecology
Academy of Disaster Reduction and Emergency Management Ministry of Civil Affairs & Ministry of Education, the People's Republic of China.
 Address:Beijing Normal University, No. 19, Xinjiekouwai Avenue,Haidian District, Beijing 100875, China
 Email:kongfeng0824@qq.com kongfeng0824@gmail.com kongfeng0824@mail.bnu.edu.cn kongfeng0824@126.com



 




------------------ Original ------------------
From: "ncl-talk-request"<ncl-talk-request@ucar.edu>;
Date: Wed, Jun 5, 2013 04:40 AM
To: "ncl-talk"<ncl-talk@ucar.edu>;

Subject: ncl-talk Digest, Vol 115, Issue 9



Send ncl-talk mailing list submissions to
        ncl-talk@ucar.edu

To subscribe or unsubscribe via the World Wide Web, visit
        http://mailman.ucar.edu/mailman/listinfo/ncl-talk
or, via email, send a message with subject or body 'help' to
        ncl-talk-request@ucar.edu

You can reach the person managing the list at
        ncl-talk-owner@ucar.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of ncl-talk digest..."


Today's Topics:

   1. Re: Fwd: Problem reading HDF5 data (Andrea Chini)
   2. Re: fatal:Subscript out of range, error in subscript #0
      (Mary Haley)
   3. Re: fatal:Subscript out of range, error in subscript #0
      (Dennis Shea)
   4. Re: problems with unstructured/conserver regridding - with
      fewer attachments (Mary Haley)


----------------------------------------------------------------------

Message: 1
Date: Tue, 04 Jun 2013 21:44:12 +0200
From: Andrea Chini <andrea.chini@meteonetwork.it>
Subject: Re: [ncl-talk] Fwd: Problem reading HDF5 data
To: ncl-talk@ucar.edu
Message-ID: <3337650.XQVXqr1bcn@dorothy>
Content-Type: text/plain; charset="us-ascii"

Hi,

yes that was the problem. I've found out that the "Segmentation fault" depend on the printVarSummary(g).

Thanks a lot.


Andrea



On Tuesday 4 June 2013 09:52:14 you wrote:
> Hi, Andrea
>
> I think you forgot to add '/' at the beginning.
>
> I tried your file and the script below worked fine:
> --------------------------------
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> f=addfile("file.h5","r")
>
> g=f->/dataset2/data1/data
> printVarSummary(g)
>
> end
> --------------------------------
> --
> HDF: Software that Powers Science
>
>
> On Mon, Jun 3, 2013 at 6:37 PM, Andrea Chini
> <andrea.chini@meteonetwork.it> wrote:
> > I have NCL 6.1.2 in a arch linux 64 bit system with kernel 3.9.2-1.
> >
> > I've uploaded the file (file.h5) in ftp server.
> >
> >
> > Andrea
> >
> >
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >


------------------------------

Message: 2
Date: Tue, 4 Jun 2013 14:12:46 -0600
From: Mary Haley <haley@ucar.edu>
Subject: Re: [ncl-talk] fatal:Subscript out of range, error in
        subscript #0
To: Luis Fernando Montana Roa <lfmontanar@unal.edu.co>
Cc: ncl-talk Talk <ncl-talk@ucar.edu>
Message-ID: <2F39CDC7-C8EC-4427-930C-C4F55D6A5606@ucar.edu>
Content-Type: text/plain; charset=iso-8859-1


On Jun 3, 2013, at 11:10 AM, Luis Fernando Montana Roa wrote:

> Mary,
> What changes should I make to this script so that I can write the same variables for all grid points, all time steps and all levels?
>
> Thanks a lot!
>
> Fernando

Fernando,

Why do you want to read in a NetCDF file and write the values out to an ASCII file?

If you are doing this for several variables across time and levels, you are going to end up with a really big ASCII file. Also, it's not easy to represent multiple dimension arrays in an ASCII file.

If I know more about why you need an ASCII file, then there may be a better solution.

--Mary

>


> On Mon, Jun 3, 2013 at 11:46 AM, Luis Fernando Montana Roa <lfmontanar@unal.edu.co> wrote:
> Mary,
> According to your suggestion, I checked the variable time (with ncdump -h) and made the following change:
>
> do it = 0, ntimes-1
>
> and it worked perfectly!
>
> Thanks
>
> Fernando
>
>
>
>
> On Mon, Jun 3, 2013 at 11:15 AM, Mary Haley <haley@ucar.edu> wrote:
> Luis,
>
> We can't debug your script for you without the data files to run it.
>
> The error message is telling you what the problem is:
>
> > fatal:Subscript out of range, error in subscript #0
> > fatal:["Execute.c":8128]:Execute: Error occurred at or near line 95 in file write_ascii.ncl
>
>
> Look at line 95 of the file and see how you are subscripting any arrays on that line. You are apparently
> using a subscript value that is out-of-range of the array size.
>
> I *think* line 95 is this one:
>
> P_in = wrf_user_getvar(in, "PSFC", time) ; Extract surface temperature
>
> Perhaps "time" is out of range. "time" is coming from this loop:
>
> do it = 0,10 ;ntimes-1
>
> If you have 10 time steps on the file, then this loop should be:
>
> do it = 0,9
>
> Better yet, you should use "ntimes:
>
> do it = 0,ntimes-1
>
> Remember that NCL does its array subscripting starting at index 0. So, if you have
> a 1D array of length 100, you can only use subscript indexes from 0 to 99.
>
> --Mary
>
> On Jun 3, 2013, at 9:10 AM, Luis Fernando Montana Roa wrote:
>
> > Dear NCL users,
> >
> > When I run the script (attached), I get the following error:
> >
> > fatal:Subscript out of range, error in subscript #0
> > fatal:["Execute.c":8128]:Execute: Error occurred at or near line 95 in file write_ascii.ncl
> >
> > I just wonder how I can fix this, and how can write the same variables for all grid points, all time steps and all levels.
> >
> > Thanks in advance
> > --
> > Fernando
> > <extract.ncl>_______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>



------------------------------

Message: 3
Date: Tue, 04 Jun 2013 14:26:01 -0600
From: Dennis Shea <shea@ucar.edu>
Subject: Re: [ncl-talk] fatal:Subscript out of range, error in
        subscript #0
To: Luis Fernando Montana Roa <lfmontanar@unal.edu.co>
Cc: ncl-talk Talk <ncl-talk@ucar.edu>
Message-ID: <51AE4D59.3010005@ucar.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

A side point.

As noted below, ascii files are extremely inefficient in terms of space.
Consider:
    x = -1234.5678

In ascii, with 8 bits (2 bytes) for each character. With 10 characters
it requires 80 bits. The same number as type 'float' takes 32 bits.


On 06/04/2013 02:12 PM, Mary Haley wrote:
>
> On Jun 3, 2013, at 11:10 AM, Luis Fernando Montana Roa wrote:
>
>> Mary,
>> What changes should I make to this script so that I can write the same variables for all grid points, all time steps and all levels?
>>
>> Thanks a lot!
>>
>> Fernando
>
> Fernando,
>
> Why do you want to read in a NetCDF file and write the values out to an ASCII file?
>
> If you are doing this for several variables across time and levels, you are going to end up with a really big ASCII file. Also, it's not easy to represent multiple dimension arrays in an ASCII file.
>
> If I know more about why you need an ASCII file, then there may be a better solution.
>
> --Mary
>
>>
>
>
>> On Mon, Jun 3, 2013 at 11:46 AM, Luis Fernando Montana Roa <lfmontanar@unal.edu.co> wrote:
>> Mary,
>> According to your suggestion, I checked the variable time (with ncdump -h) and made the following change:
>>
>> do it = 0, ntimes-1
>>
>> and it worked perfectly!
>>
>> Thanks
>>
>> Fernando
>>
>>
>>
>>
>> On Mon, Jun 3, 2013 at 11:15 AM, Mary Haley <haley@ucar.edu> wrote:
>> Luis,
>>
>> We can't debug your script for you without the data files to run it.
>>
>> The error message is telling you what the problem is:
>>
>>> fatal:Subscript out of range, error in subscript #0
>>> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 95 in file write_ascii.ncl
>>
>>
>> Look at line 95 of the file and see how you are subscripting any arrays on that line. You are apparently
>> using a subscript value that is out-of-range of the array size.
>>
>> I *think* line 95 is this one:
>>
>> P_in = wrf_user_getvar(in, "PSFC", time) ; Extract surface temperature
>>
>> Perhaps "time" is out of range. "time" is coming from this loop:
>>
>> do it = 0,10 ;ntimes-1
>>
>> If you have 10 time steps on the file, then this loop should be:
>>
>> do it = 0,9
>>
>> Better yet, you should use "ntimes:
>>
>> do it = 0,ntimes-1
>>
>> Remember that NCL does its array subscripting starting at index 0. So, if you have
>> a 1D array of length 100, you can only use subscript indexes from 0 to 99.
>>
>> --Mary
>>
>> On Jun 3, 2013, at 9:10 AM, Luis Fernando Montana Roa wrote:
>>
>>> Dear NCL users,
>>>
>>> When I run the script (attached), I get the following error:
>>>
>>> fatal:Subscript out of range, error in subscript #0
>>> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 95 in file write_ascii.ncl
>>>
>>> I just wonder how I can fix this, and how can write the same variables for all grid points, all time steps and all levels.
>>>
>>> Thanks in advance
>>> --
>>> Fernando
>>> <extract.ncl>_______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>



------------------------------

Message: 4
Date: Tue, 4 Jun 2013 14:38:45 -0600
From: Mary Haley <haley@ucar.edu>
Subject: Re: [ncl-talk] problems with unstructured/conserver
        regridding - with fewer attachments
To: Richard G French <rfrench@wellesley.edu>
Cc: ncl-talk Talk <ncl-talk@ucar.edu>
Message-ID: <EDA02401-A237-484C-8832-AC8CDCB18EF2@ucar.edu>
Content-Type: text/plain; charset="iso-8859-1"

Hi Dick,

I was able to fix the "hump" issue. You have a regional source grid in this case, so you need to set:

Opt@SrcRegional = True


I've further modified your script to attach the lat/lon corners grid (for debug purposes, although you don't really need that now), and to clean up the plotting so that it zooms in on the area of interest.
This makes it easier to see the grid. I also set gsnAddCyclic to True for the regridded data, since the cyclic point needs to be added.

See attached.

To not draw the lat/lon corners grid, simply comment out or remove this code:

;--Attach the lat_corners/lon_corners grid to the regridded plot
    nlat = dimsizes(lat_corners(:,0,0))
    nlon = dimsizes(lat_corners(0,:,0))

    line_id = new((/nlat,nlon/),graphic)
    lnres = True
    do i=0,nlat-1
      do j=0,nlon-1
        line_id(i,j) = gsn_add_polyline(wks,plot_regrid,\
                                        lon_corners(i,j,:),\
                                        lat_corners(i,j,:),lnres)
      end do
    end do

--Mary

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rgf_regrid_test_v3_mod.ncl
Type: application/octet-stream
Size: 4635 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20130604/81708119/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rgf_regrid_test_v3_wgt_conserve.png
Type: image/png
Size: 448396 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20130604/81708119/attachment.png
-------------- next part --------------


On Jun 4, 2013, at 11:24 AM, Richard G French wrote:

> That sounds like a good idea - I'm not sure how to do that, and if you think it is an easy task, I'd be grateful for the help!
>
> Dick
>
>
>
> On Tue, Jun 4, 2013 at 1:19 PM, Mary Haley <haley@ucar.edu> wrote:
> I was surprised by the differences in shapes too. Maybe it has something to do with the lat/lon_corners data on the file?
> It might be worth drawing the corners (as polylines) to see where they are with regard to the data itself.
>
> Let me know if you need help with that.
>
> --Mary
>
> On Jun 4, 2013, at 10:00 AM, Richard G French wrote:
>
> > Dear Mary,
> > Many thanks for your help on this - I'm grateful for your prompt reply. This looks promising, and I'll now try it with a denser grid to see how things look. I'm a bit surprise by the difference in shapes between the initial image and the final image, but this might be a result of the coarse gridding. The revised code will give me some ways to try some new experiments.
> > Dick
> >
> >
> >
> > On Tue, Jun 4, 2013 at 11:49 AM, Mary Haley <haley@ucar.edu> wrote:
> > Hi Richard,
> >
> > Thanks for providing your script and data.
> >
> > The problem appears to be that your curvilinear grid is being treated as a 1D unstructured grid.
> >
> > Since you have the curvilinear cell centers and corners, my recommendation is to treat this as a curvilinear grid.
> >
> > I changed your code to remove the "ndtooned" calls that were converting your lat/lon arrays to 1D, and commented out the "SrcESMF" setting (which is not really needed if you use ESMF_regrid, because this function will set this internally for you if you are using an unstructured grid).
> >
> > Here are the differences: (">" are the old lines, and "<" are the new lines):
> >
> > > Opt@SrcGridLat = ndtooned(sfile->lat_centers) ; source grid
> > > Opt@SrcGridLon = ndtooned(sfile->lon_centers)
> > 45,48c45,49
> > < if(interpMethod.eq."conserve") then
> > < Opt@GridCornerLat = sfile->lat_corners
> > < Opt@GridCornerLon = sfile->lon_corners
> > < end if
> > ---
> > > Opt@GridCornerLat = ndtooned(sfile->lat_corners)
> > > Opt@GridCornerLon = ndtooned(sfile->lon_corners)
> > >
> > > Opt@SrcGridType = "unstructured"
> > > Opt@SrcESMF = True ; unstructured format
> >
> >
> > I've included your modified script and the image.
> >
> > --Mary
> >
> >
> >
> > On Jun 3, 2013, at 8:24 PM, Richard G French wrote:
> >
> > > I'm resending this with only the critical attachments to stay under the 1500K limit. Thanks!
> > > Dick
> > >
> > >
> > > ---------- Forwarded message ----------
> > > From: Richard G French <rfrench@wellesley.edu>
> > > Date: Mon, Jun 3, 2013 at 10:20 PM
> > > Subject: problems with unstructured/conserver regridding
> > > To: ncl-talk@ucar.edu
> > >
> > >
> > > Hi, everyone -
> > >
> > > I'm having a problem getting an unstructured grid of lat/lon corners to regrid properly using the "conserve" option.
> > >
> > > I can get bilinear and patch regridding to work, but when I try "conserve", I find that my regridded data array seems to have just one element in it. The "conserve" option is essential to my application, since I need to preserve the integrated data value over the area of the regridded array.
> > >
> > > I've attached:
> > >
> > > 1) the ncl script (based on ESMF_all_conserve_12.ncl):
> > >
> > > rgf_regrid_test_v3_conserve.ncl
> > >
> > > 2) the output from running the script, with debugging turned on:
> > >
> > > ncl rgf_regrid_test_v3_conserve.ncl>ncl_script_output.txt
> > >
> > > 3) the input datafile containing the data array and the unstructured grid:
> > >
> > > rgf_regrid_test_v3small.nc
> > >
> > > 4) the ncl_filedump of this file, listing all of the variables:
> > >
> > > ncl_filedump -v flux,lon_centers,lat_centers,lon_corners,lat_corners \
> > >
> > > rgf_regrid_test_v3small.nc>ncl_filedump_output.txt
> > >
> > > 5) a postscript and PDF plot of the original data and the unsuccessful regridded version, which gives "NO CONTOUR DATA" as an error message.
> > >
> > >
> > >
> > > The script output file [2), above] shows the error messages and the problem with the regridded data array:
> > >
> > > (0) --------------------------------------------------
> > >
> > > (0) ESMF_regrid_gen_weights: 'ESMF_RegridWeightGen' was successful.
> > >
> > > (0) ESMF_regrid_with_weights: regridding using interpolation weights ...
> > >
> > > (0) ESMF_regrid_with_weights: warning: destination grid is not
> > >
> > > (0) completely covered by the source grid. This is not an error.
> > >
> > > (0) It just means your destination grid covers a larger area
> > >
> > > (0) than your source grid.
> > >
> > > (0) ESMF_regrid_with_weights: Source Grid:
> > >
> > > (0) rank: 1
> > >
> > > (0) dimensions: 15791
> > >
> > > (0) original source rank: 2
> > >
> > > (0) latitude min/max: 9.81775/79.5803
> > >
> > > (0) longitude min/max:-75.1696/9.90834
> > >
> > > (0) ESMF_regrid_with_weights: Destination Grid:
> > >
> > > (0) dimensions: 719 1440
> > >
> > > (0) latitude min/max: -89.75/89.75
> > >
> > > (0) longitude min/max:0/359.75
> > >
> > > (0) ESMF_regrid_with_weights: retrieving interpolation weights ...
> > >
> > > (0) ESMF_regrid_with_weights: error: source data on the description
> > >
> > > (0) file does not have proper dimensions.
> > >
> > > and then
> > >
> > > Variable: flux
> > >
> > > Type: double
> > >
> > > Total Size: 64000 bytes
> > >
> > > 8000 values
> > >
> > > Number of Dimensions: 2
> > >
> > > Dimensions and sizes: [ysize | 100] x [xsize | 80]
> > >
> > > Coordinates:
> > >
> > > Number Of Attributes: 1
> > >
> > > comment : Sky plane flux for occultation
> > >
> > > Variable: flux_regrid
> > >
> > > Type: float
> > >
> > > Total Size: 4 bytes
> > >
> > > 1 values
> > >
> > > Number of Dimensions: 1
> > >
> > > Dimensions and sizes: [1]
> > >
> > > I don't know why flux_regrid is a float instead of a double, or why it has only one value.
> > >
> > > I suspect that the problem comes from the way I have specified the grid corners - I created the netCDF file using IDL, and tried to make sure that the array elements are in the appropriate order, as shown in the ncl_filedump output file:
> > >
> > > variables:
> > >
> > > double flux ( ysize, xsize )
> > >
> > > comment : Sky plane flux for occultation
> > >
> > > double lon_centers ( ysize, xsize )
> > >
> > > comment : Center longitude (deg)
> > >
> > > double lat_centers ( ysize, xsize )
> > >
> > > comment : Center latitude (deg)
> > >
> > > double lon_corners ( ysize, xsize, ncorners )
> > >
> > > comment : Corner longitudes (deg)
> > >
> > > double lat_corners ( ysize, xsize, ncorners )
> > >
> > > comment : Corner latitudes (deg)
> > >
> > > but clearly there is something that I'm missing. I'd be grateful for any suggestions, and my apologies for naive questions. This is my first attempt at using ncl, which appears to be very powerful and which I hope will be useful for my application, which involves tests of atmospheric tidal models for Pluto's tenuous atmosphere.
> > >
> > > Thanks for any help anyone can provide.
> > >
> > > Dick French
> > >
> > > --
> > > Richard G. French
> > > Dean of Academic Affairs
> > > McDowell and Whiting Professor of Astrophysics
> > > Cassini Radio Science Team Leader
> > > 341A Green Hall, Wellesley College
> > > Wellesley, MA 02481-8203
> > > (781) 283-3583
> > >
> > >
> > > <ncl_script_output.txt><rgf_regrid_test_v3_conserve.ncl><rgf_regrid_test_v3small.nc><rgf_regrid_test_v3_wgt_conserve.pdf>_______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
> >
> >
> > --
> > Richard G. French
> > Dean of Academic Affairs
> > McDowell and Whiting Professor of Astrophysics
> > Cassini Radio Science Team Leader
> > 341A Green Hall, Wellesley College
> > Wellesley, MA 02481-8203
> > (781) 283-3583
>
>
>
>
> --
> Richard G. French
> Dean of Academic Affairs
> McDowell and Whiting Professor of Astrophysics
> Cassini Radio Science Team Leader
> 341A Green Hall, Wellesley College
> Wellesley, MA 02481-8203
> (781) 283-3583


------------------------------

_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


End of ncl-talk Digest, Vol 115, Issue 9
****************************************
.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 4 21:42:54 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT