[ncl-talk] FW: FW: Problem in writing the output from netcdf file

Muhammad Omer Mughal m.mughal1 at postgrad.curtin.edu.au
Thu Aug 21 20:02:33 MDT 2014


​

Thanks for the reply


The first suggestion doesnot work for me but the second one does .I dont exactly know the reason.

​

Secondly when I used u1 at _FillValue =-99 in the plot it removed the value -99 from the variable but now when I am trying to print it in ASCII format this value does not go away .


I would also like to know is there a replica for WRF function wrf_user_ll_to_ij to lock the location in the netcdf files which do not have (MAP_PROJ),(TRUELAT1),(DX),(DY) etc included in the file or this requires to write a new code or a function .


The problem as I stated before is to compare the WRF output and that of the instrument at the particular location whereas the output from the instrument is in the netcdf file . I am cleaning the code as advised by david and trying to compare the data with time in the right format but am not successful yet .Any help will be much appreciated.


Regards
Muhammad Omer Mughal
Department of Applied Physics

________________________________
From: David Brown <dbrown at ucar.edu>
Sent: Wednesday, 20 August 2014 5:56 PM
To: Muhammad Omer Mughal
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] FW: Problem in writing the output from netcdf file

In addition to what Dennis has pointed out, the thing that seems problematic to me is that you have used 'addfiles' in a loop to open individual files.
do j = 0,numfils-1,1
a = addfiles(fils(j)+".nc","r")
time=a[:]->time
u1=a[:]->vrect_x(:,:,:)
u1 at _FillValue =-99
v1=a[:]->vrect_y(:,:,:)
v1 at _FillValue =-99
​​ntim    = dimsizes(time)
       end do

This is not how addfiles is used normally. It can open all the files at once. Eliminate the do loop and use:

a = addfiles(fils + ".nc","r")

Otherwise if you want to keep the loop use "addfile" and eliminate the list-type syntax (the brackets [:]).
 -dave





On Wed, Aug 20, 2014 at 7:17 AM, Dennis Shea <shea at ucar.edu<mailto:shea at ucar.edu>> wrote:
The email text you wrote does not agree with the script you included.

[1] Please clean the script coding so it is nicely formatted. People do not have time to unravel code.

[2] As noted frequently on ncl-talk, users should include output from printVarSummary(...)
     for selected variables. This is not just for ncl-talk to examine but also you. Please
     examine the output.

[3] The email text states "The netcdf files are from the instrument but are not in the regular
     netcdf format meaning that the time is not included in the dimensions of the variables
     to be extracted". This is not clear.

     Yet your code has

         u1   = a[:]->vrect_x      ; (:,:,:)

     and subsequently

         data(npt) = data(npt) + sprintf("%7.1f ",u1(nt,nl,ml))

     where  u1 references a time dimension via subscrip 'nt' . Very confusing.

[4] You use

       x     = (/ntim,nlat,mlon/)

       If you were to use

       printVarSummary(x)

       you would see that it is a one dimensional array of tyope integer and length 3.

      Later you use

      data(npt) = data(npt) + sprintf("%10.3f ", x(nt))

      why x(nt)????







On Tue, Aug 19, 2014 at 11:52 PM, Muhammad Omer Mughal <m.mughal1 at postgrad.curtin.edu.au<mailto:m.mughal1 at postgrad.curtin.edu.au>> wrote:


Hi everyone

I am running NCL version 6.1.0. I have to write output from multiple netcdf file into the ascii fromat containing wind speed comparison at a particular latitude and longitude.This aim is to get the comparison from the wrf ouput and the instrument at a particular location. The netcdf files are from the instrument but are not in the regular netcdf format meaning that the time is not included in the dimensions of the variables  to be extracted  and each file contains one value of time.​The first problem that I am facing is that the fill value is not getting deleted in the ascii output.I use the following to generated the ascii output .

b=addfile("/20090711/20090711_000239_01_g.nc<http://20090711_000239_01_g.nc>","r")
lon=b->yp(0,0,:)
lat=b->xp(0,:,0)
DATADir = "./"
fils = systemfunc (" ls -1 " + DATADir + "/20090711* ")
numfils = dimsizes(fils)
do j = 0,numfils-1,1
a = addfiles(fils(j)+".nc","r")
time=a[:]->time
::::::::::::::
::::::::::       npt  = npt + 1
       data(npt) = sprinti("%0.5i", (npt+1) )
       data(npt) = data(npt) + sprintf("%7.1f ",lat(nl))
       data(npt) = data(npt) + sprintf("%7.1f ",lon(ml))
      do nt=0,ntim-1
         data(npt) = data(npt) + sprintf("%10.3f ", x(nt))
data(npt) = data(npt) + sprintf("%7.1f ",u1(nt,nl,ml))
data(npt) = data(npt) + sprintf("%7.1f ",v1(nt,nl,ml))
      end do
    end do
  end do
  asciiwrite (fName , data)
​In this way I get the output that is attached .Any help to correct this code will be appreciated



Regards
Muhammad Omer Mughal
Department of Applied Physics


_______________________________________________
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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140822/e7e66af3/attachment.html 


More information about the ncl-talk mailing list