def calculate_em(self, wlen='171', dz=100, model=False): """ Calculate an approximation of the coronal EmissionMeasure using a given TemperatureMap object and a particular AIA channel. Parameters ---------- tmap : CoronaTemps.temperature.TemperatureMap A TemperatureMap instance containing coronal temperature data wlen : {'94' | '131' | '171' | '193' | '211' | '335'} AIA wavelength used to approximate the emission measure. '171', '193' and '211' are most likely to provide reliable results. Use of other channels is not recommended. """ # Load the appropriate temperature response function tresp = read('/imaps/holly/home/ajl7/CoronaTemps/aia_tresp') resp = tresp['resp{}'.format(wlen)] # Get some information from the TemperatureMap and set up filenames, etc tempdata = self.data.copy() tempdata[np.isnan(tempdata)] = 0.0 date = sunpy.time.parse_time(self.date) if not model: data_dir = self.data_dir fits_dir = path.join(data_dir, '{:%Y/%m/%d}/{}'.format(date, wlen)) filename = path.join(fits_dir, '*{0:%Y?%m?%d}?{0:%H?%M}*fits'.format(date)) if wlen == '94': filename = filename.replace('94', '094') # Load and appropriately process AIA data filelist = glob.glob(filename) if filelist == []: print 'AIA data not found :(' return aiamap = Map(filename) aiamap.data /= aiamap.exposure_time aiamap = aiaprep(aiamap) aiamap = aiamap.submap(self.xrange, self.yrange) else: fname = '/imaps/holly/home/ajl7/CoronaTemps/data/synthetic/{}/model.fits'.format(wlen) if wlen == '94': fname = fname.replace('94', '094') aiamap = Map(fname) # Create new Map and put EM values in it emmap = Map(self.data.copy(), self.meta.copy()) indices = np.round((tempdata - 4.0) / 0.05).astype(int) indices[indices < 0] = 0 indices[indices > 100] = 100 #print emmap.shape, indices.shape, tempdata.shape, aiamap.shape, resp.shape emmap.data = np.log10(aiamap.data / resp[indices]) #emmap.data = aiamap.data / resp[indices] emmapcubehelix = _cm.cubehelix(s=2.8, r=-0.7, h=1.4, gamma=1.0) cm.register_cmap(name='emhelix', data=emmapcubehelix) emmap.cmap = cm.get_cmap('emhelix') return emmap
# Load AIA response functions resp = load_temp_responses() # Load unnessecary map for its metadata voidmap = Map(sunpy.AIA_171_IMAGE) mapmeta = voidmap.meta #rect = patches.Rectangle([25.0, 5.6], 1.0, 1.0, color='black', fill=True, clip_on=False) # Run synthetic data through 1param tempmap method for w, wid in enumerate(widths):#heights): print '\nWidth:', wid fig = plt.figure(figsize=(30, 12)) for wl, wlength in enumerate(['94', '131', '171', '193', '211', '335']): #emiss = Map(emission[wl, :, :, w], mapmeta) emiss = Map(emission[wl, :, w, :].copy(), mapmeta) emiss.cmap = sunpy.cm.get_cmap('sdoaia{}'.format(wlength)) emiss.meta['naxis1'] = emiss.shape[1] emiss.meta['naxis2'] = emiss.shape[0] #emiss.meta['cdelt1'] = widths[1] - widths[0] emiss.meta['cdelt1'] = heights[1] - heights[0] #np.log10(heights[1]) - np.log10(heights[0]) emiss.meta['cdelt2'] = temps[1] - temps[0] #emiss.meta['crval1'] = widths[0] emiss.meta['crval1'] = heights[0] #np.log10(heights[0]) emiss.meta['crval2'] = temps[0] emiss.meta['crpix1'] = 0.5 emiss.meta['crpix2'] = 0.5 if wlength == '94': wlength = '094' fits_dir = path.join(CThome, 'data', 'synthetic', wlength) if not path.exists(fits_dir): makedirs(fits_dir) emiss.save(path.join(fits_dir, 'model.fits'), clobber=True) #print '----', emission[2, :, :, :].min(), emission[2, :, :, :].max()