;For a given component, combine all the given orbit strips into a single ;"daisy" plot. The level 3A server runs this for each component to create ;the level 3A product from the level 2 product. ; ;Input ; l2 - An array of Level 2 structures (not pointers to l2 structures), ; or more generally, an array of structures with a center_lon field ; l2_COMPONENT - An array of Level 2 components to merge, of the same ; length as the l2 array. This should be an array of pointers ; to 2D images. ; ;Output ; bbox - The bounding box of the level 3A image. Right now, this box bounds ; the entire map. The units of this bounding box are TILES, not map ; pixels. ; ;Returns ; A single 2D array, of the same type as l2_component, which has the level 2 ; strips rotated and merged into a single daisy plot ; ;An example of typical usage, since this is called in an unusual way. ; ; L3A_albedo = combine_1c(Level_2_array,Level_2_array.albedo,bbox=bbox) ; L3A_ozone = combine_1c(Level_2_array,Level_2_array.ozone) ; L3A_hratio = combine_1c(Level_2_array,Level_2_array.hratio) ; ;Note that both the Level 2 structure as a whole, and one component of the ;structure, are passed in at the same time. function combine_2,l2,l2_component,bbox=bbox,_extra=extra,mgcount=mgcount maps=ptrarr(n_elements(L2_component)) bboxes=intarr(n_elements(l2_component),4) for i=0, n_elements(l2_component)-1 do begin if ptr_valid(l2_component[i]) then begin component=*(l2_component[i]) map_size=map_size_lambert(_extra=extra) map=make_array(map_size,map_size,type=size(component,/type),value=!values.f_nan) xmin=l2[i].bbox[0] ymin=l2[i].bbox[1] s=size(component,/dimensions) xmax=xmin+s[0]-1 ymax=ymin+s[1]-1 if xmin lt 0 then xmin=0 if ymin lt 0 then ymin=0 if xmax ge map_size then xmax=map_size-1 if ymax ge map_size then ymax=map_size-1 xspan=xmax-xmin+1 yspan=ymax-ymin+1 map[xmin:xmax,ymin:ymax]=component[0:xspan-1,0:yspan-1] maps[i]=ptr_new(rot(map,-l2[i].center_lon,missing=!values.f_nan)) bboxes[i,*]=[0,0,map_size-1,map_size-1] endif else begin ; else if invalid component pointer print, 'invalid component pointer: ' help, l2_component[i] endelse endfor result=merge(maps,bboxes,_extra=extra,bbox=bbox,mgcount=mgcount) bbox=findbbox(finite(result)) result=result[bbox[0]:bbox[2]-1,bbox[1]:bbox[3]-1] str_free,maps return,result end