function c3_massimg,bn,fn,save=save,only_ne=only_ne,new=new COMMON cme_massimg,base,hbase,calbase,bname ; ; Check to see if the base image is new and if it is then ; Read in the base image and calibrate it. ; Store the calibrated image and header into the common array for next time ; s = SIZE(bname) newflag = 0 IF (KEYWORD_SET(new)) THEN newflag=1 IF ((s(0) NE 0) OR (s(1) NE 7)) THEN newflag=1 ELSE $ IF (bname NE bn) THEN newflag=1 IF (newflag EQ 1) THEN BEGIN base = LASCO_READFITS(bn,hbase) calbase = C3_CALIBRATE(base,hbase) bname = bn ENDIF hb = hbase calb = calbase a = LASCO_READFITS(fn,ha) PRINT PRINT,'PROCESSING File: ',fn PRINT,'TIME ',ha.date_OBS+' '+ha.time_obs PRINT ; ; Now calibrate the CME image ; cala = C3_CALIBRATE(a,ha) ; ; Determine the summing for each image and rebin both images to no ; summing if they are different. Adjust the headers to reflect the ; changes. ; sumxb = (hb.sumcol>1)*hb.lebxsum sumyb = (hb.sumrow>1)*hb.lebysum sumxa = (ha.sumcol>1)*ha.lebxsum sumya = (ha.sumrow>1)*ha.lebysum IF (sumxb NE sumxa) OR (sumyb NE sumya) THEN BEGIN calb = REBIN (calb, hb.naxis1*(sumxb/sumxa), hb.naxis2*(sumyb/sumya)) hb.lebxsum = sumxa/(hb.sumcol>1) hb.lebysum = sumya/(hb.sumrow>1) sb = SIZE(calb) hb.naxis1 = sb(1) hb.naxis2 = sb(2) ENDIF ; ; Check the size of the two images and match ; nx = ha.naxis1 ny = ha.naxis2 IF ((nx NE hb.naxis1) OR (ny NE hb.naxis2)) THEN BEGIN ; ; find the least common area, determine the starting ; and ending columns and rows,corrected for summing ; ; r1col = ha.r1col>hb.r1col r2col = ha.r2col<hb.r2col r1row = ha.r1row>hb.r1row r2row = ha.r2row<hb.r2row xa1 = (r1col-ha.r1col)/sumxa xa2 = (xa1+r2col-r1col)/sumxa ya1 = (r1row-ha.r1row)/sumya ya2 = (ya1+r2row-r1row)/sumya xb1 = (r1col-hb.r1col)/sumxa xb2 = (xb1+r2col-r1col)/sumxa yb1 = (r1row-hb.r1row)/sumya yb2 = (yb1+r2row-r1row)/sumya ; ; extract the common image area ; cala = cala(xa1:xa2,ya1:ya2) calb = calb(xb1:xb2,yb1:yb2) ; ; update the two image headers for the new image ; boundaries and sizes ; ha.r1col = r1col hb.r1col = r1col ha.r1row = r1row hb.r1row = r1row ha.r2col = r1col hb.r2col = r2col ha.r2row = r2row hb.r2row = r2row ha.naxis1 = xa2-xa1+1 hb.naxis1 = ha.naxis1 ha.naxis2 = ya2-ya1+1 hb.naxis2 = ha.naxis2 nx = ha.naxis1 ny = ha.naxis2 ENDIF ; ; Now normalize the images, difference them ; sxa=10 sxb=ha.naxis1-10 sya=ha.naxis2-10 syb=ha.naxis2-5 asub=cala(sxa:sxb,sya:syb) bsub=calb(sxa:sxb,sya:syb) w = WHERE(asub GT 0,nw) rsub = bsub(w)/asub(w) fac = AVERAGE(rsub) dif = cala*fac-calb ; ; Calculate the mass and convert to float from double precision ; IF (NOT KEYWORD_SET(save)) THEN save=0 IF (NOT KEYWORD_SET(only_ne)) THEN only_ne=0 mass = FLOAT(CALC_CME_MASS(dif,ha,/all,FNAME=save,ONLY_NE=only_ne)) fname = ha.filename ; ; Set the file type to indicate mass image and the source ; If source is 2 (level-0) then file type is 7 ; else file type is 6 ; source = STRMID(fname,1,1) IF (source EQ '2') THEN filetype='7' ELSE filetype='6' ha.filename=STRMID(fname,0,1)+filetype+STRMID(fname,2,STRLEN(fname)) FXADDPAR,h,'SIMPLE','T' FXADDPAR,h,'BITPIX',32 FXADDPAR,h,'NAXIS',2 w = WHERE(ha.history EQ '',nw) ha.history(w(0)) = 'C3_MASSIMG: ('+hb.filename+','+fname+')' w = WHERE(ha.comment EQ '',nw) ha.comment(w(0)) = 'Base Image: '+hb.filename+' '+hb.date_obs+' '+hb.time_obs ha.DATAMAX=max(mass) IF KEYWORD_SET(only_ne) THEN ha.BUNIT='ELECTRONS/PIXEL' $ ELSE ha.BUNIT='GRAMS/PIXEL' h = DERIVFITSHDR(ha,hdr=h) WRITEFITS,ha.filename,mass,h ; RETURN,mass END