From 28a2c0c46e3a0baa5e7448db3a29fc53c6e4832d Mon Sep 17 00:00:00 2001 From: Gilles Otten Date: Sat, 9 Nov 2024 02:19:05 +0800 Subject: [PATCH 1/6] Updated README.md with tested installation instructions --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a2e2c57..b614527 100755 --- a/README.md +++ b/README.md @@ -39,5 +39,11 @@ You can use this tool to check all versions: [check_versions.ipynb](https://gith [![Astropy](https://img.shields.io/badge/Astropy-3.2.3-brightgreen.svg)]() [![Skimage](https://img.shields.io/badge/Skimage-0.18.3-brightgreen.svg)]() +## Installation instructions + +Install python 3.10.4 +Install pip install astropy==5.0.4 scopesim==0.5.0 vip_hci==1.0.3 numpy==1.22.3 photutils==0.7.2 + + ## Quick start This Jupyter Notebook will walk you through a simple HEEPS simulation: [demo.ipynb](https://github.com/vortex-exoplanet/HEEPS/blob/master/notebooks/demo.ipynb) From a7110b3eddd3219d32a68c66f144ca4c0e88e3d8 Mon Sep 17 00:00:00 2001 From: Gilles Otten Date: Sat, 9 Nov 2024 02:20:04 +0800 Subject: [PATCH 2/6] Edit to README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b614527..2675288 100755 --- a/README.md +++ b/README.md @@ -42,7 +42,8 @@ You can use this tool to check all versions: [check_versions.ipynb](https://gith ## Installation instructions Install python 3.10.4 -Install pip install astropy==5.0.4 scopesim==0.5.0 vip_hci==1.0.3 numpy==1.22.3 photutils==0.7.2 +Install pip +pip install astropy==5.0.4 scopesim==0.5.0 vip_hci==1.0.3 numpy==1.22.3 photutils==0.7.2 ## Quick start From 6997f7654e6690d3a2913bd3de0083414ea87fbd Mon Sep 17 00:00:00 2001 From: Gilles Otten Date: Sat, 9 Nov 2024 03:38:28 +0800 Subject: [PATCH 3/6] HEEPS + Scopesim Imager update --- heeps/config/read_config.py | 3 +- heeps/contrast/background.py | 130 ++++++++++++++++- heeps/contrast/sim_heeps.py | 265 ++++++++++++++++++++++++++--------- 3 files changed, 323 insertions(+), 75 deletions(-) diff --git a/heeps/config/read_config.py b/heeps/config/read_config.py index 83671b6..e4a7a09 100644 --- a/heeps/config/read_config.py +++ b/heeps/config/read_config.py @@ -89,6 +89,7 @@ def read_config(verbose=False, **update_conf): flux_star = 8.999e+10, # [e-/s] HCI-L long, mag 0 (Jan 21, 2020) flux_bckg = 8.878e+04, # [e-/s/pix] call_ScopeSim = False, # true if interfacing ScopeSim + ScopeSim_LMS = False, # true if using LMS mode duration = 3600, # duration of the ADI sequence in s dit = 0.3, # detector integration time in s lat = -24.59, # telescope latitude in deg (Armazones=-24.59 ,Paranal -24.63) @@ -229,4 +230,4 @@ def read_config(verbose=False, **update_conf): # sort alphabetically conf = {k: v for k, v in sorted(conf.items())} - return conf \ No newline at end of file + return conf diff --git a/heeps/contrast/background.py b/heeps/contrast/background.py index d48b56e..88679d9 100644 --- a/heeps/contrast/background.py +++ b/heeps/contrast/background.py @@ -1,5 +1,6 @@ import numpy as np from astropy.io import fits +from heeps.contrast.sim_heeps import sim_heeps def background(psf_ON, psf_OFF, header=None, mode='RAVC', lam=3.8e-6, dit=0.3, mag=5, mag_ref=0, flux_star=9e10, flux_bckg=9e4, app_single_psf=0.48, @@ -65,9 +66,110 @@ def background(psf_ON, psf_OFF, header=None, mode='RAVC', lam=3.8e-6, dit=0.3, # scopesim-heeps interface if call_ScopeSim is True: - from heeps.contrast.sim_heeps import sim_heeps - psf_ON, psf_OFF = sim_heeps(psf_ON, psf_OFF, header, **conf) - else: + + hdu=fits.PrimaryHDU(data=psf_ON) + hdu.header.append("CDELT1") + hdu.header.append("CDELT2") + hdu.header.append("CTYPE1") + hdu.header.append("CTYPE2") + hdu.header.append("CUNIT1") + hdu.header.append("CUNIT2") + hdu.header.append("CPIX1") + hdu.header.append("CPIX2") + hdu.header.append("CVAL1") + hdu.header.append("CVAL2") + hdu.header.append("BUNIT") + hdu.header.append("OFFAXISTRANS") + hdu.header.append("MODE") + hdu.header.append("BAND") + hdu.header.append("LAM") + hdu.header.append("FILTER") + if conf['ScopeSim_LMS'] == True: + hdu.header.append("NAXIS3") + hdu.header.append("CDELT3") + hdu.header.append("CUNIT3") + hdu.header.append("CPIX3") + hdu.header.append("CVAL3") + + for band in conf['band_specs']: + print(band,conf['band_specs'][band]['lam']) + if np.abs(conf['band_specs'][band]['lam'] - lam)<0.05e-6: + hdu.header['BAND']=band + hdu.header['LAM']=lam + + + if hdu.header['BAND']=="L": + hdu.header["FILTER"]="HCI_L_long" + elif hdu.header['BAND']=="M": + hdu.header["FILTER"]="CO_ref" + elif hdu.header['BAND']=="N1": + hdu.header["FILTER"]="N1" + elif hdu.header['BAND']=="N2": + hdu.header["FILTER"]="N2" + elif hdu.header['BAND']=="N1a": + hdu.header["FILTER"]="N1" # no N2a exists in Scopesim + elif hdu.header['BAND']=="N2a": + hdu.header["FILTER"]="N2" # no N2a exists in Scopesim + hdu.header['MODE']=mode + + hdu.header.append("BCKGTRANS") + if data is not None: + hdu.header['OFFAXISTRANS']=thruput*mask_trans + hdu.header['BCKGTRANS']=thruput*mask_trans + else: + hdu.header['OFFAXISTRANS']=thruput + hdu.header['BCKGTRANS']=thruput + if 'APP' in mode: + hdu.header['OFFAXISTRANS']=hdu.header['OFFAXISTRANS']*app_single_psf # the invididual APP PSF contains a fraction (~48%) of the light passing through the coronagraph optics, but the background still 100% of the light passing through coronagraph. + psf_OFF=np.median(psf_ON,0) + hdu.header['CDELT1']=conf['band_specs'][hdu.header['BAND']]['pscale']*0.000277778/1000. + hdu.header['CDELT2']=conf['band_specs'][hdu.header['BAND']]['pscale']*0.000277778/1000. # mas to degrees + print(conf) + hdu.header['EXPTIME']=dit #conf['dit'] + hdu.header["CTYPE1"] = 'RA---TAN' + hdu.header["CTYPE2"] = 'DEC--TAN' + hdu.header['CUNIT1']='deg' + hdu.header['CUNIT2']='deg' + if conf['ScopeSim_LMS']==False: + hdu.header['BUNIT']="photons/s" # BUNIT overridden by use of Vega spectrum in scopesim + print("band is ",hdu.header['BAND']) + if hdu.header['BAND'] in ["N1","N2","N1a","N2a"]: + hdu.header['CRPIX1']=163 + hdu.header['CRPIX2']=163 + else: + hdu.header["CRPIX1"]=202 + hdu.header["CRPIX2"]=202 + hdu.header["CRVAL1"]=0 + hdu.header["CRVAL2"]=0 + + if conf['ScopeSim_LMS']==True: + hdu.header['NAXIS1']=403#2048 + hdu.header['NAXIS2']=403#2048##conf['band_specs'][hdu.header['BAND']]['pscale']*0.000277778/1000. # mas to degrees + hdu.header['NAXIS3']=20 + #hdu.header['CDELT1']=5.78*0.000277778/1000. + #hdu.header['CDELT2']=5.78*0.000277778/1000.##conf['band_specs'][hdu.header['BAND']]['pscale']*0.000277778/1000. # mas to degrees +# print(conf) + hdu.header['CDELT3']=0.00005 + hdu.header['EXPTIME']=6#0.011#dit#conf['dit'] + hdu.header["CTYPE1"] = 'RA---TAN' + hdu.header["CTYPE2"] = 'DEC--TAN' + hdu.header['CUNIT1']='deg' + hdu.header['CUNIT2']='deg' + hdu.header['CUNIT3']='um' + hdu.header['BUNIT']="erg/cm^2/s/angstrom" # BUNIT overridden by use of Vega spectrum in scopesim + hdu.header["CRPIX1"]=202#1024 + hdu.header["CRPIX2"]=202#1024 # this needs to be half of naxis1 otherwise it will put the star at the wrong center + hdu.header["CRPIX3"]=0 + hdu.header["CRVAL1"]=0 + hdu.header["CRVAL2"]=0 + hdu.header["CRVAL3"]=hdu.header['LAM']/1e-6 # start value of wavelength range in microns + psf_ON=np.repeat(psf_ON[:,np.newaxis,:,:],hdu.header['NAXIS3'],axis=1) + + header=hdu.header + print(conf) + psf_ON, psf_OFF = sim_heeps(psf_ON*10**(-0.4*(mag-0.)), psf_OFF*10**(-0.4*(mag-0.)), header,**conf) # note, mask_trans and offaxis_trans not yet transferred to background + + else: # if not passed to ScopeSim # rescale PSFs to star signal star_signal = dit * flux_star * 10**(-0.4*(mag - mag_ref)) psf_OFF *= star_signal * mask_trans @@ -79,8 +181,22 @@ def background(psf_ON, psf_OFF, header=None, mode='RAVC', lam=3.8e-6, dit=0.3, np.random.seed(seed) psf_ON += np.random.normal(0, np.sqrt(psf_ON)) - if verbose is True: - print(' dit=%s s, thruput=%.4f, mask_trans=%.4f,'%(dit, thruput, mask_trans)) - print(' mag=%s, star_signal=%.2e, bckg_noise=%.2e'%(mag, star_signal, bckg_noise)) + if data is None: + mask_trans=1. + + if (verbose is True) and (call_ScopeSim==False): + print(' offaxis_trans=%3.4f, mask_trans=%3.4f,'%(thruput, mask_trans)) + print(' mag=%s, dit=%3.3f'%(mag, dit)) + print(' star_signal=%3.2E, bckg_noise=%3.2E'%(star_signal, bckg_noise)) + elif (verbose is True) and (call_ScopeSim==True) and (conf['ScopeSim_LMS']==False): + print(' SCOPESIM MODE: some values biased') + print(' offaxis_trans=%3.4f, mask_trans=%3.4f,'%(thruput, mask_trans)) + print(' mag=%s, dit=%3.3f'%(mag, dit)) + print(' star_signal=%3.4f, bckg_noise=%3.4f'%(np.sum(psf_OFF)/thruput/mask_trans, np.median(psf_ON))) + elif (verbose is True) and (call_ScopeSim==True) and (conf['ScopeSim_LMS']==True): + print(' SCOPESIM LMS MODE: some values biased') + print(' offaxis_trans=%3.4f, mask_trans=%3.4f,'%(thruput, mask_trans)) + print(' mag=%s, dit=%3.3f'%(mag, dit)) + print(' star_signal=%3.4f, bckg_noise=%3.4f'%(np.sum(psf_OFF)/thruput/mask_trans, np.median(psf_ON))) - return psf_ON, psf_OFF \ No newline at end of file + return psf_ON, psf_OFF diff --git a/heeps/contrast/sim_heeps.py b/heeps/contrast/sim_heeps.py index 813eb3b..3fc1191 100644 --- a/heeps/contrast/sim_heeps.py +++ b/heeps/contrast/sim_heeps.py @@ -1,6 +1,5 @@ """ ScopeSim processing of a HCI (RAVC) data cube produced by HEEPS - The cube contains the temporal evolution of the coronagraphic PSF using the METIS RAVC in the L band. ScopeSim uses the cube as the input source and produced detector images with background and detector noise components. @@ -11,92 +10,224 @@ from astropy.io import fits from astropy.wcs import WCS from astropy import units as u - +import matplotlib.pyplot as plt import scopesim as sim +import scipy.ndimage +from heeps.util.save2fits import save2fits + + +#sim.download_package(['instruments/METIS', 'telescopes/ELT', 'locations/Armazones']) from synphot import SourceSpectrum # Change if you want to use another cube -FNAME = "cube_Cbasic_20201130_3600s_300ms_onaxis_PSF_L_RAVC_fullM1_scao_only.fits" +#FNAME = "onaxis_PSF_L_RAVC.fits" -# Change if the output file name is too stupid -OUTFILE = "heeps_scopesimed.fits" - -# Change FLUX_SCALE to vary the star's brightness relative to Vega -FLUX_SCALE = 1. +WORKDIR = "./" +PKGSDIR = "./inst_pkgs/" # This sets the path to the METIS configuration. Change the path to # match your setup. PKGS_DIR = os.path.abspath( os.path.join( - os.path.dirname("/home/oczoske/ELT_Development/irdb/METIS"))) + os.path.dirname(PKGSDIR))) sim.rc.__config__['!SIM.file.local_packages_path'] = PKGS_DIR - - -def sim_heeps(): + + +list_lm=[ + "HCI_L_long", + "HCI_L_short", + "Lp", + "short-L", + "L_spec", + "Mp", + "M_spec", + "Br_alpha", + "Br_alpha_ref", + "PAH_3.3", + "PAH_3.3_ref", + "CO_1-0_ice", + "CO_ref", + "H2O-ice", + "IB_4.05", + "HCI_M"] +def sim_heeps(psf_ON, psf_OFF, header, **conf): """Do the simulation""" - # Prepare the source - cube = fits.open(FNAME) - imwcs = WCS(cube[0].header).sub([1, 2]) - naxis1, naxis2, naxis3 = (cube[0].header['NAXIS1'], - cube[0].header['NAXIS2'], - cube[0].header['NAXIS3']) - + offaxistrans=header['OFFAXISTRANS'] # this number transfers the transmission of the coronagraphic optics as seen by an off-axis source, per PSF (in case of APP). + bckgtrans=header['BCKGTRANS'] # same but for a background source, the difference is when the APP is used. which only contains 48% of the off-axis flux per PSF +# print(offaxistrans) + + # pre-compensate PSF_OFF and PSF_ON for bckgtrans + psf_OFF=psf_OFF/bckgtrans + psf_ON=psf_ON/bckgtrans + + + # Exposure parameters + dit = header['EXPTIME'] +# header['FILTER']="HCI_L_short" + #header['FILTER']='PAH_3.3' OVERRIDE FOR TESTING + ndit = 1 # Set up the instrument - cmd = sim.UserCommands(use_instrument='METIS', set_modes='img_lm') - + #cmd = sim.UserCommands(use_instrument='METIS', set_modes=['img_lm']) + #print(conf) + if conf['ScopeSim_LMS']==False: # for IMG_LM or IMG_N modes + naxis1, naxis2, naxis3 = (header['NAXIS1'], + header['NAXIS2'], + header['NAXIS3']) + if header['FILTER'] in list_lm: # IMG_LM mode + cmd=sim.UserCommands(use_instrument="METIS", set_modes=["img_lm"],properties={"!OBS.filter_name": header['FILTER'],"!OBS.auto_exposure.fill_frac":1e6,"!OBS.exptime":dit,"!OBS.ndit":ndit,"!OBS.dit": dit,"!OBS.detector_readout_mode":"fast","!OBS.pupil_transmission":bckgtrans}) + cmd2=sim.UserCommands(use_instrument="METIS", set_modes=["img_lm"],properties={"!OBS.filter_name": header['FILTER'],"!OBS.auto_exposure.fill_frac":1e20,"!OBS.exptime":dit,"!OBS.ndit":ndit,"!OBS.dit": dit,"!OBS.detector_readout_mode":"fast","!OBS.pupil_transmission":bckgtrans}) + else: # this is IMG_N + cmd=sim.UserCommands(use_instrument="METIS", set_modes=["img_n"],properties={"!OBS.filter_name": header['FILTER'],"!OBS.auto_exposure.fill_frac":1e6,"!OBS.exptime":dit,"!OBS.ndit":ndit,"!OBS.dit": dit,"!OBS.detector_readout_mode":"high_capacity","!OBS.pupil_transmission":bckgtrans}) + cmd2=sim.UserCommands(use_instrument="METIS", set_modes=["img_n"],properties={"!OBS.filter_name": header['FILTER'],"!OBS.auto_exposure.fill_frac":1e20,"!OBS.exptime":dit,"!OBS.ndit":ndit,"!OBS.dit": dit,"!OBS.detector_readout_mode":"high_capacity","!OBS.pupil_transmission":bckgtrans}) + elif conf['ScopeSim_LMS']==True: + naxis1, naxis2, naxis3,naxis4 = (header['NAXIS1'], + header['NAXIS2'], + header['NAXIS3'],np.shape(psf_ON)[0]) + if header['FILTER'] in ["HCI_L_long","CO_ref"]: + cmd = sim.UserCommands(use_instrument='METIS', set_modes=['lms'],properties={"!OBS.exptime": dit, + "!SIM.spectral.spectral_resolution": 2000, + "!SIM.spectral.spectral_bin_width": 1e-3,'!OBS.wavelen':header['lam']/1e-6,"!OBS.pupil_transmission":bckgtrans,"!OBS.auto_exposure.fill_frac":1e6}) + #cmd2=sim.UserCommands(use_instrument="METIS", set_modes=["img_lm"],properties={"!OBS.filter_name": header['FILTER'],"!OBS.auto_exposure.fill_frac":1e20,"!OBS.exptime":dit,"!OBS.ndit":ndit,"!OBS.dit": dit,"!OBS.detector_readout_mode":"fast"}) + # somewhere we need to set the cold stop pupil to the off-axis transmission to reduce the background flux correctly + # similarly we need to rescale the on-axis and off-axis PSFs to pre-correct for that factor. + # Set up detector size to match the input cube - using the full # METIS detector of 2048 x 2048 pixels would require too much memory - cmd["!DET.width"] = naxis1 - cmd["!DET.height"] = naxis2 - - metis = sim.OpticalTrain(cmd) - - # Set included and excluded effects - metis['armazones_atmo_skycalc_ter_curve'].include = True - metis['armazones_atmo_default_ter_curve'].include = False - - metis['scope_surface_list'].include = False - metis['eso_combined_reflection'].include = True - - metis['detector_array_list'].include = False - metis['detector_window'].include = True - - metis['scope_vibration'].include = False - metis['detector_linearity'].include = False - metis['metis_psf_img'].include = False - + + if conf['ScopeSim_LMS']==False: + cmd["!DET.width"] = naxis1 + cmd["!DET.height"] = naxis2 + + metis_on = sim.OpticalTrain(cmd) + metis_on['psf'].include=False + if conf['ScopeSim_LMS']==True: # LMS mode + + nplanes = 12000 + #nplanes = naxis3 # for full cube + #naxis4=np.shape(psf_ON)[0] + print(psf_ON.shape,"psf shape") + nplanes = min(nplanes, naxis4) + #psf_ON_out=np.zeros([nplanes,naxis3,naxis1,naxis2]) + for n in np.arange(nplanes): + new_wl=header['CRVAL3']+np.arange(naxis3)*header['CDELT3'] + print(new_wl) + vega=fits.getdata(WORKDIR+"alpha_lyr_stis_008.fits") + #mag=5 + vega_flux=vega["FLUX"] # angstrom to micron + vega_wave=vega['WAVELENGTH']/10000. # ergs/cm^2/s/angstrom + + f_flux=scipy.interpolate.interp1d(vega_wave,vega_flux) + new_flux=f_flux(new_wl) + #new_flux[500:600]=0 + hdu=fits.PrimaryHDU(data=new_flux[:,np.newaxis,np.newaxis]*psf_ON[n,:,:,:],header=header) + src_on=sim.source.source.Source(cube=hdu,flux=0*u.mag) + metis_on.observe(src_on,update=True) + result = metis_on.readout(detector_readout_mode="auto")[0] + fig,ax=plt.subplots(2,2) + print(result[1].header) + ax[0,0].imshow(result[2].data,origin="lower") + + ax[1,0].imshow(result[3].data,origin="lower") + + ax[0,1].imshow(result[1].data,origin="lower") + + ax[1,1].imshow(result[4].data,origin="lower") + plt.show() + plt.close() + + elif conf['ScopeSim_LMS']==False: + metis_sum = sim.OpticalTrain(cmd) + metis_sum['psf'].include=False + metis_off = sim.OpticalTrain(cmd2) + metis_off['psf'].include=False + metis_off['readout_noise'].include=False + metis_off['shot_noise'].include=False + metis_bkg = sim.OpticalTrain(cmd2) + metis_bkg['psf'].include=False + metis_bkg['readout_noise'].include=False + metis_bkg['shot_noise'].include=False + #print(metis_bkg.effects) # We attach the spectrum of Vega to the image - spec = SourceSpectrum.from_file("alpha_lyr_stis_008.fits") - - - # Exposure parameters - dit = cube[0].header['CDELT3'] - ndit = 1 + spec = SourceSpectrum.from_file(WORKDIR+"alpha_lyr_stis_008.fits") # Loop over the input cube - nplanes = 100 - # nplanes = naxis3 # for full cube - - nplanes = min(nplanes, naxis3) - - for i in range(nplanes): - print("Plane", i+1, "/", nplanes) - imhdu = fits.ImageHDU(header=imwcs.to_header(), - data=cube[0].data[i, :, :] * FLUX_SCALE) - src = sim.Source(spectra=[spec], image_hdu=imhdu) - - metis.observe(src) - outhdu = metis.readout(dit=dit, ndit=ndit)[0] - cube[0].data[i, :, :] = outhdu[1].data.astype(np.float32) - - # We have filled up the original cube with the simulated data - # Write out only the simulated planes - fits.writeto(OUTFILE, data=cube[0].data[:nplanes, :, :], - header=cube[0].header, - overwrite=True) - + nplanes = 12000 + #nplanes = naxis3 # for full cube + nplanes = min(nplanes, naxis3) + #nplanes=4 + psf_ON_out=np.zeros([nplanes,naxis1,naxis2]) + psf_SUM_out=np.zeros([nplanes,naxis1,naxis2]) + psf_SUM=np.zeros([nplanes,naxis1,naxis2]) + psf_OFF_out=np.zeros([naxis1,naxis2]) + + hourangles=np.linspace(-0.5/24.*360.,0.5/24.*360.,nplanes) + + lat = -24.59 # deg + dec = -51.0665168055 # deg -51 == beta pic + hr = np.deg2rad(hourangles) + dr = np.deg2rad(dec) + lr = np.deg2rad(lat) +# parallactic angle in deg + pa = -np.rad2deg(np.arctan2(-np.sin(hr), np.cos(dr)*np.tan(lr) + - np.sin(dr)*np.cos(hr))) + pa = (pa + 360)%360 + pa_rad = np.deg2rad(pa) + ang_sep=100. + xy = np.array([ang_sep*np.cos(np.pi/2.+pa_rad), ang_sep*np.sin(np.pi/2.+pa_rad)]).T + for n in np.arange(nplanes): + if header['FILTER'] in list_lm: # LM band + psf_SUM[n,:,:]=psf_ON[n,:,:]+scipy.ndimage.shift((10**(-0.4*7.7)*psf_OFF[:,:]),(xy[n,0]/5.47,xy[n,1]/5.47))#+scipy.ndimage.shift((10**(-0.4*7.7)*psf_OFF[:,:]),(xy[n,0]/5.47,xy[n,1]/5.47)) + else: #n-band + psf_SUM[n,:,:]=psf_ON[n,:,:]+scipy.ndimage.shift((10**(-0.4*5)*psf_OFF[:,:]),(xy[n,0]/5.47,xy[n,1]/5.47))#+scipy.ndimage.shift((10**(-0.4*5)*psf_OFF[:,:]),(xy[n,0]/5.47,xy[n,1]/5.47)) + + for i in range(nplanes): + print("Plane", i+1, "/", nplanes) + print(np.sum(psf_ON[i,:,:])) + imhdu_on=fits.PrimaryHDU(data=psf_ON[i,:,:],header=header) + imhdu_off=fits.PrimaryHDU(data=psf_OFF/10000.,header=header) # the off-axis reference should not be saturated; hack to prevent saturation + imhdu_sum=fits.PrimaryHDU(data=psf_SUM[i,:,:],header=header) + src_on = sim.Source(spectra=[spec], image_hdu=imhdu_on) + src_off = sim.Source(spectra=[spec], image_hdu=imhdu_off) + src_sum = sim.Source(spectra=[spec], image_hdu=imhdu_sum) + src_bkg = sim.source.source_templates.empty_sky() + + metis_on.observe(src_on,update=True) + metis_off.observe(src_off,update=True) + metis_bkg.observe(src_bkg,update=True) + metis_sum.observe(src_sum,update=True) + #print(metis_bkg['detector_readout_parameters'].list_modes()) + outhdu = metis_on.readout()[0] + outhdu2 = metis_off.readout()[0] + outhdu3 = metis_bkg.readout()[0] + outhdu4 = metis_sum.readout()[0] + num=np.int32((naxis1-1)/2) + print(outhdu[0].header) + print(outhdu[1].header) + psf_ON_out[i,:,:] = outhdu[1].data.astype(np.float32)[(1024-num):(1024+num+1),(1024-num):(1024+num+1)] + psf_OFF_out = outhdu2[1].data[(1024-num):(1024+num+1),(1024-num):(1024+num+1)]-outhdu3[1].data[(1024-num):(1024+num+1),(1024-num):(1024+num+1)] + psf_OFF_out = psf_OFF_out*10000. # restore flux level to original scale + psf_SUM_out[i,:,:] = outhdu4[1].data.astype(np.float32)[(1024-num):(1024+num+1),(1024-num):(1024+num+1)] + newheader_ON=outhdu + newheader_OFF=outhdu2 + newheader_SUM=outhdu4 + if conf['ScopeSim_LMS']==False: + newheader_ON[1].data=psf_ON_out + newheader_OFF[1].data=psf_OFF_out + newheader_SUM[1].data=psf_SUM_out + newheader_ON[1].header['CRPIX1']=num+1 + newheader_OFF[1].header['CRPIX1']=num+1 + newheader_SUM[1].header['CRPIX1']=num+1 + newheader_ON[1].header['CRPIX2']=num+1 + newheader_OFF[1].header['CRPIX2']=num+1 + newheader_SUM[1].header['CRPIX2']=num+1 + + if True: + newheader_ON.writeto("scopesim_on_scopesim_{0}_{1}.fits".format(header["MODE"],header["FILTER"]),overwrite=True) + newheader_OFF.writeto("scopesim_off_scopesim_{0}_{1}.fits".format(header["MODE"],header["FILTER"]),overwrite=True) + newheader_SUM.writeto("scopesim_sum_scopesim_{0}_{1}.fits".format(header["MODE"],header["FILTER"]),overwrite=True) + return psf_ON_out, psf_OFF_out if __name__ == "__main__": sim_heeps() From 03aebed108daae768ebafb709419a2aa5305f506 Mon Sep 17 00:00:00 2001 From: Gilles Otten Date: Sat, 9 Nov 2024 03:42:13 +0800 Subject: [PATCH 4/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2675288..3c91d12 100755 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ You can use this tool to check all versions: [check_versions.ipynb](https://gith Install python 3.10.4 Install pip -pip install astropy==5.0.4 scopesim==0.5.0 vip_hci==1.0.3 numpy==1.22.3 photutils==0.7.2 +pip install astropy==5.3.4 scopesim==0.8.4 vip_hci==1.0.3 numpy==1.26.4 photutils==0.7.2 ## Quick start From 501b63c9d5651fffca5a2247943d27c83ccfbc8d Mon Sep 17 00:00:00 2001 From: Gilles Otten Date: Sat, 9 Nov 2024 03:43:32 +0800 Subject: [PATCH 5/6] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3c91d12..205a97f 100755 --- a/README.md +++ b/README.md @@ -41,9 +41,9 @@ You can use this tool to check all versions: [check_versions.ipynb](https://gith ## Installation instructions -Install python 3.10.4 -Install pip -pip install astropy==5.3.4 scopesim==0.8.4 vip_hci==1.0.3 numpy==1.26.4 photutils==0.7.2 +- Install python 3.10.4 +- Install pip +- pip install astropy==5.3.4 scopesim==0.8.4 vip_hci==1.0.3 numpy==1.26.4 photutils==0.7.2 ## Quick start From 1cb04acc77730c97f291cd69ae5b810c5986e84d Mon Sep 17 00:00:00 2001 From: Gilles Otten Date: Sat, 9 Nov 2024 03:44:17 +0800 Subject: [PATCH 6/6] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 205a97f..6cb3f41 100755 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ You can use this tool to check all versions: [check_versions.ipynb](https://gith [![Astropy](https://img.shields.io/badge/Astropy-3.2.3-brightgreen.svg)]() [![Skimage](https://img.shields.io/badge/Skimage-0.18.3-brightgreen.svg)]() -## Installation instructions +## Installation instructions compatible with ScopeSim - Install python 3.10.4 - Install pip