Re: get values from wrfout file for all lat, lon points

From: Luis Fernando Montana Roa <lfmontanar_at_nyahnyahspammersnyahnyah>
Date: Thu Oct 03 2013 - 06:18:08 MDT

Sorry, I had failed to attach the script. There goes.

-- Fernando

On Thu, Oct 3, 2013 at 7:16 AM, Luis Fernando Montana Roa <
lfmontanar@unal.edu.co> wrote:

> Thanks Mary, I did the settings with your suggestions and tried the script
> attached. But when I run it, get the following error:
>
> fatal:NclMalloc Failed:[errno=12]
> fatal:Exp: Could not allocate memory for result type, can't continue
>
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 25 in
> file w_2.ncl
>
> -- Fernando
>
>
> On Wed, Oct 2, 2013 at 2:25 PM, Mary Haley <haley@ucar.edu> wrote:
>
>> I think you simply need to change the "do" loop that writes out the ASCII
>> file so that it writes the whole arrays, rather than one time step at a
>> time.
>>
>> For example, instead of:
>>
>> line = new(ntimes+1,string)
>>
>> line(0) = " Time Temperature Pressure
>> Relative_Humidity U V Wind_speed"
>>
>> do it = 0,ntimes-1
>>
>> line(it+1) = sprintf("%5.0f",it) +" " \
>> +sprintf("%18.2f", T_C(it)) +" " \
>> +sprintf("%12.2f", P(it)) +" " \
>> +sprintf("%12.2f", RH(it)) +" " \
>> +sprintf("%12.2f", ua) +" " \
>> +sprintf("%12.2f", va) +" " \
>> +sprintf("%12.2f", wind_speed(it))
>>
>> end do
>>
>> You can do this (UNTESTED):
>>
>> filename = "out_2_1.txt"
>> format = "%5.0f %18.2f %12.2f %12.2f %12.2f %12.2f %12.2f"
>> write_table(filename,"w",header,"%s")
>> write_table(filename,"w",[/it, t_C, P, RH, ua, va,
>> wind_speed/],format)
>>
>> --Mary
>>
>>
>> On Oct 1, 2013, at 8:35 PM, Luis Fernando Montana Roa <
>> lfmontanar@unal.edu.co> wrote:
>>
>> > Thanks Mary, what I need is to write an ascii file with variable values
>> for each time step and grid point, as shown below.:
>> >
>> > Time Lat Lon Temp Pres RH U V
>> Wind_speed
>> > 0 -10.0 -85.0 20.89 101.05 92.24 1.58 -1.26 2.02
>> > 0 -10.0 -84.5 19.94 101.01 96.16 2.18 -1.6 2.7
>> > ...
>> > 0 -9.5 -85.0 19.94 101.01 96.16 2.18 -1.6 2.7
>> > 0 -9.5 -84.5 19.65 101.04 96.88 2.84 -1.4 3.17
>> > ...
>> > 1 -10.0 -85.0 19.94 101.01 96.16 2.18 -1.6 2.7
>> > 1 -10.0 -84.5 19.65 101.04 96.88 2.84 -1.4 3.17
>> > ...
>> > 1 -9.5 -85.0 19.37 101015.75 97.29 3.09 -0.98
>> 3.24
>> > 1 -9.5 -84.5 19.08 101026.23 97.51 3.23 -0.76
>> 3.32
>> > ...
>> >
>> > I will appreciate any help in this regard.
>> >
>> > -- Fernando
>> >
>> > ---------- Forwarded message ----------
>> > From: Mary Haley <haley@ucar.edu>
>> > Date: Tue, Oct 1, 2013 at 3:03 PM
>> > Subject: Re: get values from wrfout file for all lat,lon
>> points
>> > To: Luis Fernando Montana Roa <lfmontanar@unal.edu.co>
>> > Cc: ncl-talk@ucar.edu
>> >
>> >
>> > Hi Luis,
>> >
>> > I'm not sure exactly sure of your question. You don't need to get
>> individual point locations for one lat/lon pair at a time. You can simply
>> do the calculation across all lat/lon values.
>> >
>> > For example, instead of this do loop:
>> >
>> > do it = 0,ntimes-1
>> >
>> > time = it
>> > Latitude = 4.16
>> > Longitude = -74.87
>> >
>> > res = True
>> > res@returnInt = True
>> > point = wrf_user_ll_to_ij(in,Longitude,Latitude,res)
>> >
>> > x = point(0)
>> > y = point(1)
>> >
>> > U = wrf_user_getvar(in, "U", time)
>> > ua_in = wrf_user_unstagger(U,U@stagger)
>> > ua = ua_in(0:0,x,y)
>> > V = wrf_user_getvar(in, "V", time)
>> > va_in = wrf_user_unstagger(V,V@stagger)
>> > va = va_in(0:0,x,y)
>> > wind_speed(it) = sqrt(ua^2+va^2)
>> > copy_VarCoords(ua,wind_speed(it))
>> > wind_speed@Units= "m/s"
>> >
>> > T_in = wrf_user_getvar(in, "T2", time)
>> > T_k = T_in(x,y)
>> > T_C(it) = T_k-273.15
>> > T_C@Units="°C"
>> >
>> > P_in = wrf_user_getvar(in, "PSFC", time)
>> > P(it) = P_in(x,y)
>> > P_rh=P_in(x,y)
>> >
>> > Q_in = wrf_user_getvar(in, "Q2", time)
>> > Q(it) = Q_in(x,y)
>> > Q_rh=Q_in(x,y)
>> >
>> > RH(it) = wrf_rh(Q_rh, P_rh, T_k)
>> >
>> > end do
>> >
>> > I think you can just do this, using the special value of -1 for time:
>> >
>> > time = -1
>> > U = wrf_user_getvar(in, "U", time) ; This will get U
>> across all times, lats, and lons
>> > ua = wrf_user_unstagger(U,U@stagger)
>> > V = wrf_user_getvar(in, "V", time)
>> > va = wrf_user_unstagger(V,V@stagger)
>> > wind_speed( = sqrt(ua^2+va^2)
>> > copy_VarCoords(ua,wind_speed)
>> > wind_speed@Units= "m/s"
>> >
>> > T = wrf_user_getvar(in, "T2", time)
>> > T_C = T-273.15
>> > T_C@Units="°C"
>> >
>> > Q_rh = wrf_user_getvar(in, "Q2", time)
>> > P_rh = wrf_user_getvar(in, "PSFC", time)
>> > RH = wrf_rh(Q_rh, P_rh, T_k)
>> >
>> >
>> >
>> >
>> > On Sep 30, 2013, at 4:47 PM, Luis Fernando Montana Roa <
>> lfmontanar@unal.edu.co> wrote:
>> >
>> > > Hi, I have this script to write the values of some variables to a
>> single point. How do I adjust it for all points (lat, lon) available in the
>> file?
>> > > Thanks,
>> > >
>> > > --
>> > > Fernando
>> > > <w_v_x.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
>>
>>
>

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

Received on Thu Oct 3 06:18:19 2013

This archive was generated by hypermail 2.1.8 : Fri Oct 04 2013 - 16:45:17 MDT