For Mode 1: Read in maskfile and specfile Call spscale in gofutils in goflib call CAL_setState call CAL_spdetmap to retrieve spdetmap_RP from CCF n = 0 spsum = 0. do i=0,XsizeM-1 do ii=0,YsizeM-1 if (mask_IP(i,ii) .gt. 0) then n = n + 1 spsum = spsum + spdetmap_RP(i,ii) endif enddo enddo spsum = spsum / real(n) Return Print backscal, avg SP flare flux, scaled avg SP flare flux For Mode 2: Open and read text file list of masks/spectra Loop through list as in Mode 1