;+ ; Copy the data container from in to out. ; ; This procedure can be used to generate a new data container, or to ; copy one data container into an existing data container. However, it ; cannot be used to copy into one of the global data containers. ; To copy a data container stored as a local variable into a global ; data container, use the procedure set_data_container. ; ; @param in {in}{required}{type=data_container} The data container ; copied. This can be identified by a local valiable or it can be ; a global data container, such as !g.s[0] ; ; @param out {out}{required}{type=data_container} The data container to receive ; the copy. This can be a local variable, but NOT a global data container. ; ; @examples ;
; get, mc_scan=22, cal='F', sig='T', pol='XX', if_num=1, int=1 ; sig
; data_copy,!g.s[0],spec
; a = getdcdata(spec)
; a = a * 2.0
; setdcdata,spec,a
; show,spec
; data_free, spec  ; clean up memory
; 
; ; @version $Id: data_copy.pro,v 1.6 2005/05/30 04:03:43 bgarwood Exp $ ;- PRO DATA_COPY, in, out compile_opt idl2 ; check on match in data_struct's type if (data_valid(in, name=name) eq -1) then begin message, 'in must be a valid continuum or spectrum structure',/info return endif if (data_valid(out) ne -1) then begin data_free, out endif ; copy everything out = in ; now, make the pointers actual copies and not just copies of the pointers ; assumes all pointers in in are valid out.data_ptr = ptr_new(*in.data_ptr) if (name eq 'CONTINUUM') then begin out.date = ptr_new(*in.date) out.utc = ptr_new(*in.utc) out.mjd = ptr_new(*in.mjd) out.longitude_axis = ptr_new(*in.longitude_axis) out.latitude_axis = ptr_new(*in.latitude_axis) out.lst = ptr_new(*in.lst) out.azimuth = ptr_new(*in.azimuth) out.elevation = ptr_new(*in.elevation) endif return end