Re: regarding the retention of coordinate variables

From: Daniel Barandiaran <dbarandiaran_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 20 2013 - 08:52:37 MDT

Dennis: The point you brought up with the equation had certainly crossed
my mind, which is why I had asked specifically about the coordinates, and
not all metadata. Nonetheless, different coordinate names would complicate
the issue, and sometimes I have run across instances where two arrays had
the same size and shape, but the coordinates were shifted by, say 1/2
degree for one of them, which I can see would be confusing to deal with
internally.

Mary: The list of _Wrap functions is much longer than I had realized! I
had not thought much of the potential cost of carrying over metadata, but
this along with Dennis' point, are definitely good reasons to have NCL
default as not carrying over metadata. Your suggestion of adding to
contributed.ncl is a good one though, and when I am not busy with my own
list of projects I will definitely be adding something in there to satisfy
my desire for neater code.

Thanks to both of you for your response!

On Mon, Aug 19, 2013 at 10:04 PM, <shea@ucar.edu> wrote:

> Also ... If you think an equation
>
> A = B*C/Q + 5.2 +linint2(.....) + (T/conform(T,1,p))^0.286
>
> What meta data is appropriate? In particular, what attributes would you
> associate with variable 'A'
>
> long_name? units?
> Consider that B, C, Q, T, p may have attributes that are appropriate
> for that variable but not to the result 'A'
>
> Coordinates? Q may have coordinate variables but maybe B and C don't.
> Further, T may have coordinates but with different names?
> How is NCL to unravel this situation?
>
> The only attribute handle automatically is _FillValue. In the above,
> 'A'will get the _FillValue assigned the the 1st variable encountered
> (Here, B)
>
>
>
>
>
>
>
>
> > Hi Danny,
> >
> > This is a good question.
> >
> > Copying over coordinate data and/or attributes can be an expensive
> > operation, both time-wise and memory-wise, especially if you have large
> > arrays and/or lots of arrays.
> >
> > I believe it was a conscious decision when NCL was first being developed
> > to have this NOT be the default behavior, and to let the user manage
> this.
> >
> > We do provide special _Wrap versions of some functions which copy over
> > meta data, but unfortunately not for the ones that you listed.
> >
> > It may not be very hard to add your own _Wrap versions of the functions
> > you listed.
> >
> > Look at the fie:
> >
> > $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
> >
> > and search for "_Wrap ("
> >
> > You will see that all of these functions have corresponding "_Wrap"
> > versions that work exactly the same as their non-_Wrap counterparts,
> > except they add metadata:
> >
> > area_conserve_remap_Wrap
> > area_hi2lores_Wrap
> > cssgrid_Wrap
> > dim_avg_Wrap
> > dim_avg_n_Wrap
> > dim_avg_wgt_Wrap
> > dim_avg_wgt_n_Wrap
> > dim_cumsum_Wrap
> > dim_cumsum_n_Wrap
> > dim_max_n_Wrap
> > dim_min_n_Wrap
> > dim_rmsd_Wrap
> > dim_rmsd_n_Wrap
> > dim_rmvmean_Wrap
> > dim_rmvmean_n_Wrap
> > dim_rmvmed_Wrap
> > dim_rmvmed_n_Wrap
> > dim_standardize_Wrap
> > dim_standardize_n_Wrap
> > dim_stddev_Wrap
> > dim_stddev_n_Wrap
> > dim_sum_Wrap
> > dim_sum_n_Wrap
> > dim_sum_wgt_Wrap
> > dim_sum_wgt_n_Wrap
> > dim_variance_Wrap
> > dim_variance_n_Wrap
> > dv2uvF_Wrap
> > dv2uvG_Wrap
> > eofcor_Wrap
> > eofcor_pcmsg_Wrap
> > eofcor_ts_Wrap
> > eofcov_Wrap
> > eofcov_pcmsg_Wrap
> > eofcov_ts_Wrap
> > eofunc_Wrap
> > eofunc_ts_Wrap
> > eofunc_varimax_Wrap
> > f2fosh_Wrap
> > f2foshv_Wrap
> > f2fsh_Wrap
> > f2fshv_Wrap
> > f2gsh_Wrap
> > f2gshv_Wrap
> > fo2fsh_Wrap
> > fo2fshv_Wrap
> > g2fsh_Wrap
> > g2fshv_Wrap
> > g2gsh_Wrap
> > g2gshv_Wrap
> > ilapsF_Wrap
> > ilapsG_Wrap
> > int2p_Wrap
> > int2p_n_Wrap
> > linint1_Wrap
> > linint1_n_Wrap
> > linint2_Wrap
> > natgrid_Wrap
> > obj_anal_ic_Wrap
> > rcm2rgrid_Wrap
> > rgrid2rcm_Wrap
> > shsgc_R42_Wrap
> > triple2grid_Wrap
> > uv2dvF_Wrap
> > uv2dvG_Wrap
> > uv2vrF_Wrap
> > uv2vrG_Wrap
> > vr2uvF_Wrap
> > vr2uvG_Wrap
> > wgt_areaave_Wrap
> > zonal_mpsi_Wrap
> >
> > You might be able to use one of these as a template for adding your own
> > _Wrap versions of the functions you enquired about.
> >
> > --Mary
> >
> > On Aug 19, 2013, at 3:17 PM, Daniel Barandiaran <dbarandiaran@gmail.com>
> > wrote:
> >
> >> Hi NCLers,
> >>
> >> This question is specifically for the developers. In my work I make
> >> frequent use for functions such as escorc, regCoef,
> >> center_finite_diff_n, and I am sure there are others for which my
> >> problem is applicable, but they slip my mind at the moment. Anyway, my
> >> question is this: these functions do not retain the coordinate variables
> >> in the output; why not? I am sure there is a reason for this, and I am
> >> also well-aware of tricks like copy_VarCoords, or pre-assigning the
> >> variable name in such a way that coordinate variables are assigned
> >> before the desired function is used, but this adds lines to my code. I
> >> have been on a quest, if you will, to make my codes shorter and sleeker,
> >> and this is a frequent thorn in my side. Maybe I am being too
> >> nit-picky, and I have no doubt that you all have more pressing things on
> >> your plate than to satisfy the desires of my quest for short code, but I
> >> am curious as to why this wasn't worked into functions such as this in
> >> the first place. No hur
> > ry on this one, and as always I greatly appreciate all the work you guys
> > do for all of us NCL users.
> >>
> >> --
> >> Danny Barandiaran
> >> Department of Plants, Soils, and Climate
> >> Utah State University
> >>
> >>
> >> _______________________________________________
> >> 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
> >
>
>
>

-- 
Danny Barandiaran
Department of Plants, Soils, and Climate
Utah State University

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Aug 20 08:52:57 2013

This archive was generated by hypermail 2.1.8 : Wed Aug 21 2013 - 13:54:15 MDT