Re: subtracting vectors from a netcdf file

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu Sep 06 2012 - 14:17:03 MDT

On Sep 6, 2012, at 2:04 PM, Mariangel Fedrizzi wrote:

> Dear All,
>
> Thanks for the reply. That works.
>
> It is interesting that before going to the nc-talk I tried a similar way, but it didn't work.
>
> I tried:
>
> u_pl14 = u(95,14,:,:)
> u_pl09 = u(95,9,:,:)
>
> v_pl14 = v(95,14,:,:)
> v_pl09 = v(95,9,:,:)
>
> delta_u = u_pl14 - u_pl09
> delta_v = v_pl14 - v_pl09
>
> plot = gsn_csm_vector_map_polar(wks,delta_u,delta_v,res)
>
> I guess I didn't preserve the metadata?

Probably. Specifically your original variables most likely have coordinate variables attached to them. New variables (like your 'delta_u') that get created as a result of binary operators like minus lose all metadata. Try using printVarSummary on some of your variables to see their metadata at any point in your script.
 -dave

>
> Thanks!
> Mariangel
>
>
> On Thu, Sep 6, 2012 at 1:01 PM, David Brown <dbrown@ucar.edu> wrote:
> ; preserve the metadata
> usub = u(95,14,:,:)
> vsub = v(95,14,:,:)
> ; do the subtraction
> usub = u(95,9,:,:) - u(95,14,:,:)
> vsub = v(95,9,:,:) - v(95,14,:,:)
> plot = gsn_csm_vector_map_polar(wks,usub,vsub,res)
>
> I think that is all there is to it.
> -dave
>
>
> On Sep 6, 2012, at 12:55 PM, Mariangel Fedrizzi wrote:
>
>> Hi,
>>
>> Is there an easy way to subtract winds at two different pressure levels from a netcdf file, in the ncl script?
>>
>> I have:
>>
>> Dimensions and sizes for a: [time | 96] x [plev | 15] x [lat | 90] x [lon | 20]
>> a = addfile("file.nc","r")
>> t = a->time
>> u = a->zonal_wind
>> v = a->meridional_wind
>>
>> I need to subtract:
>>
>> u(95,14,:,:) from u(95,9,:,:)
>>
>> and
>>
>> v(95,14,:,:) from v(95,9,:,:)
>>
>> and plot the resultant vector on a stereographic polar projection, which is already working for any given pressure level using:
>> plot = gsn_csm_vector_map_polar(wks,u(95,9,:,:),v(95,9,:,:),res)
>>
>> In summary, I need to plot the resulting wind vector from the subtraction between values at two different pressure levels, but same time, lat, lon. These numbers are in the same netcdf file.
>>
>> Thanks.
>>
>> Best,
>> Mariangel.
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> ===============================================
> Mariangel Fedrizzi, Ph.D.
>
> NOAA/SWPC - University of Colorado/CIRES
> 325 Broadway
> Boulder, CO 80305
> Tel: 1-303-497-3833
> Fax: 1-303-497-3645
> E-mail: Mariangel.Fedrizzi@noaa.gov
> ===============================================
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 6 14:17:23 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT