diff --git a/Catalog/C6_50sqdeg.py b/Catalog/C6_50sqdeg.py index d1a59e5f3de27b8f50a4eacb516487c78394c116..3c21fad47379696a7a449ae255db8bc7a72014d9 100644 --- a/Catalog/C6_50sqdeg.py +++ b/Catalog/C6_50sqdeg.py @@ -344,8 +344,8 @@ class Catalog(CatalogBase): ) for istars in range(nstars): # (TEST) - if istars > 100: - break + # if istars > 100: + # break param = self.initialize_param() param['ra'] = ra_arr[istars] diff --git a/ObservationSim/Config/ChipOutput.py b/ObservationSim/Config/ChipOutput.py index 8d237d0bb43404e5b3e6204e72f1564661bd0427..44253f1d43c4e2913418e87d7ab9f7af23c0e6d0 100755 --- a/ObservationSim/Config/ChipOutput.py +++ b/ObservationSim/Config/ChipOutput.py @@ -1,8 +1,9 @@ import os import logging +import ObservationSim.Config._util as _util class ChipOutput(object): - def __init__(self, config, focal_plane, chip, filt, imgKey0="", imgKey1="", imgKey2="", exptime=150., mjdTime="", ra_cen=None, dec_cen=None, pointing_type='MS', pointing_ID='0', subdir="./", prefix=""): + def __init__(self, config, focal_plane, chip, filt, imgKey0="", imgKey1="", imgKey2="", exptime=150., mjdTime="", ra_cen=None, dec_cen=None, pointing_type='SCI', pointing_ID='0', subdir="./", prefix=""): self.focal_plane = focal_plane self.chip = chip self.filt = filt @@ -20,12 +21,15 @@ class ChipOutput(object): self.dec_cen = config["obs_setting"]["dec_center"] self.chipLabel = focal_plane.getChipLabel(chip.chipID) - self.cat_name = "MSC_1%s_chip_%s_filt_%s"%(str(pointing_ID).rjust(8, '0'), self.chipLabel, filt.filter_type) + ".cat" + obs_id = _util.get_obs_id(img_type=pointing_type, project_cycle=config["project_cycle"], run_counter=config["run_counter"], pointing_num=pointing_ID) + # self.cat_name = "MSC_1%s_chip_%s_filt_%s"%(str(pointing_ID).rjust(8, '0'), self.chipLabel, filt.filter_type) + ".cat" + self.cat_name = "MSC_%s_chip_%s_filt_%s"%(obs_id, self.chipLabel, filt.filter_type) + ".cat" self.subdir = subdir # Setup logger for each chip - logger_filename = "MSC_1%s_chip_%s_filt_%s"%(str(pointing_ID).rjust(8, '0'), self.chipLabel, filt.filter_type) + ".log" + # logger_filename = "MSC_1%s_chip_%s_filt_%s"%(str(pointing_ID).rjust(8, '0'), self.chipLabel, filt.filter_type) + ".log" + logger_filename = "MSC_%s_chip_%s_filt_%s"%(obs_id, self.chipLabel, filt.filter_type) + ".log" self.logger = logging.getLogger() fh = logging.FileHandler(os.path.join(self.subdir, logger_filename), mode='w+', encoding='utf-8') fh.setLevel(logging.DEBUG) @@ -56,7 +60,7 @@ class ChipOutput(object): self.hdr += additional_column_names def create_output_file(self): - if self.pointing_type == 'MS': + if self.pointing_type == 'SCI': self.cat = open(os.path.join(self.subdir, self.cat_name), "w") self.logger.info("Creating catalog file %s ...\n"%(os.path.join(self.subdir, self.cat_name))) if not self.hdr.endswith("\n"): diff --git a/ObservationSim/Config/Header/ImageHeader.py b/ObservationSim/Config/Header/ImageHeader.py index 8bf9d28c8c00e18f4c3d65ae43eecab5b35e469e..3a7673f2a1f0aba5c722081d074b2415b33427a5 100644 --- a/ObservationSim/Config/Header/ImageHeader.py +++ b/ObservationSim/Config/Header/ImageHeader.py @@ -17,6 +17,7 @@ from astropy.coordinates import SkyCoord from astropy.wcs.utils import fit_wcs_from_points from astropy.time import Time from astropy import wcs +from ObservationSim.Config._util import get_obs_id, get_file_type from datetime import datetime # import socket @@ -341,7 +342,7 @@ def WCS_def(xlen = 9216, ylen = 9232, gapy = 898.0, gapx1 = 534, gapx2 = 1309, r #TODO project_cycle is temporary, is not in header defined, delete in future -def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec = -40, pixel_scale = 0.074, date='200930', time_obs='120000', im_type = 'MS', exptime=150., sat_pos = [0.,0.,0.], sat_vel = [0., 0., 0.], project_cycle=6, chip_name="01"): +def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec = -40, pixel_scale = 0.074, date='200930', time_obs='120000', im_type = 'MS', exptime=150., sat_pos = [0.,0.,0.], sat_vel = [0., 0., 0.], project_cycle=6, run_counter=0, chip_name="01"): # array_size1, array_size2, flux, sigma = int(argv[1]), int(argv[2]), 1000.0, 5.0 @@ -376,18 +377,21 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec h_prim['OBJ_RA'] = ra h_prim['OBJ_DEC'] = dec - obs_type = {'SCI': '01', 'BIAS': '03', 'DARK': '07', 'FLAT': '11', 'CRS': '98', 'CRD': '99'} + # obs_type = {'SCI': '01', 'BIAS': '03', 'DARK': '07', 'FLAT': '11', 'CRS': '98', 'CRD': '99'} - OBS_id = '1'+ obs_type[im_type] + str(int(project_cycle)) + pointNum.rjust(7,'0') + # # OBS_id = '1'+ obs_type[im_type] + str(int(project_cycle)) + pointNum.rjust(7,'0') + # OBS_id = '1'+ obs_type[im_type] + str(int(project_cycle)) + str(int(run_counter)).rjust(2, '0') + pointNum.rjust(5,'0') + OBS_id = get_obs_id(img_type=im_type, project_cycle=project_cycle, run_counter=run_counter, pointing_num=pointNum) h_prim['OBJECT'] = str(int(project_cycle)) + pointNum.rjust(7,'0') h_prim['OBSID'] = OBS_id # h_prim['TELFOCUS'] = 'f/14' h_prim['EXPTIME'] = exptime - # Define file types - file_type = {'SCI':'SCIE', 'BIAS':'BIAS', 'DARK':'DARK', 'FLAT':'FLAT', 'CRS':'CRS', 'CRD':'CRD','CALS':'CALS','CALF':'CALF'} - h_prim['FILETYPE'] = file_type[im_type] + # # Define file types + # file_type = {'SCI':'SCIE', 'BIAS':'BIAS', 'DARK':'DARK', 'FLAT':'FLAT', 'CRS':'CRS', 'CRD':'CRD','CALS':'CALS','CALF':'CALF'} + # h_prim['FILETYPE'] = file_type[im_type] + h_prim['FILETYPE'] = get_file_type(img_type=im_type) co = coord.SkyCoord(ra, dec, unit='deg') @@ -422,7 +426,7 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec file_end_time = end_time_str[0:4] + end_time_str[5:7]+end_time_str[8:10] + end_time_str[11:13] + end_time_str[14:16] + end_time_str[17:19] # h_prim['FILENAME'] = 'CSST_MSC_MS_' + im_type + '_' + file_start_time + '_' + file_end_time + '_' + OBS_id + '_' + CCDID[ # k - 1].rjust(2, '0') + '_L0_V01' - h_prim['FILENAME'] = 'CSST_MSC_MS_' + file_type[im_type] + '_' + file_start_time + '_' + file_end_time + '_' + OBS_id + '_' + chip_name + '_L0_V01' + h_prim['FILENAME'] = 'CSST_MSC_MS_' + h_prim['FILETYPE'] + '_' + file_start_time + '_' + file_end_time + '_' + OBS_id + '_' + chip_name + '_L0_V01' h_prim['POSI0_X'] = sat_pos[0] diff --git a/ObservationSim/Config/Pointing.py b/ObservationSim/Config/Pointing.py index 9308c87f67147d70767eff61614283f429ce852a..6c17ea4a414d5ec494fc81e43c667bf47e70f987 100644 --- a/ObservationSim/Config/Pointing.py +++ b/ObservationSim/Config/Pointing.py @@ -2,8 +2,10 @@ import numpy as np import galsim from astropy.time import Time +import ObservationSim.Instrument._util as _util + class Pointing(object): - def __init__(self, id=0, ra=0., dec=0., img_pa=0., timestamp=1621915200, sat_x=0., sat_y=0., sat_z=0., sun_x=0., sun_y=0., sun_z=0., sat_vx=0., sat_vy=0., sat_vz=0., exp_time=150., pointing_type='MS'): + def __init__(self, id=0, ra=0., dec=0., img_pa=0., timestamp=1621915200, sat_x=0., sat_y=0., sat_z=0., sun_x=0., sun_y=0., sun_z=0., sat_vx=0., sat_vy=0., sat_vz=0., exp_time=150., pointing_type='SCI'): self.id = id self.ra = ra self.dec = dec @@ -14,9 +16,33 @@ class Pointing(object): self.sat_vx, self.sat_vy, self.sat_vz = sat_vx, sat_vy, sat_vz self.exp_time = exp_time self.pointing_type = pointing_type - self.jdt = 0. + self.survey_field_type = 'WIDE' + self.jdt = 0. + + def get_full_depth_exptime(self, filter_type): + if self.survey_field_type == 'WIDE': + if filter_type in _util.SPEC_FILTERS: + return 150. * 4 + else: + if filter_type.lower() in ['nuv', 'y']: + return 150. * 4 + elif filter_type.lower() in ['u', 'g', 'r', 'i', 'z']: + return 150. * 2 + else: + return max(150., self.exp_time) # [TODO] for FGS + elif self.survey_field_type == 'DEEP': + if filter_type in _util.SPEC_FILTERS: + return 250. * 4 * 4 + else: + if filter_type.lower() in ['nuv', 'y']: + return 250. * 4 * 4 + elif filter_type.lower() in ['u', 'g', 'r', 'i', 'z']: + return 250. * 2 * 4 + else: + return max(150., self.exp_time) # [TODO] for FGS + - def read_pointing_columns(self, columns, id=0, t=1621915200, pointing_type='MS'): + def read_pointing_columns(self, columns, id=0, t=1621915200, pointing_type='SCI'): self.id = id col_len = len(columns) self.ra = float(columns[0]) @@ -38,5 +64,9 @@ class Pointing(object): self.sat_vy = float(columns[16]) self.sat_vz = float(columns[17]) self.exp_time = float(columns[18]) + is_deep = float(columns[19]) + # [TODO] Can also define other survey types + if is_deep != -1.0: + self.survey_field_type = "DEEP" else: self.timestamp = t diff --git a/ObservationSim/Instrument/Chip/Chip.py b/ObservationSim/Instrument/Chip/Chip.py index bb93b0a202ad4e04f4267ed4b8b7fcf9d0b2e02c..fa0abe8c569a452f7f989f2864be5e97ab77b92e 100755 --- a/ObservationSim/Instrument/Chip/Chip.py +++ b/ObservationSim/Instrument/Chip/Chip.py @@ -3,6 +3,7 @@ import os import numpy as np import pickle import json +import ObservationSim.Instrument._util as _util from astropy.table import Table from numpy.random import Generator, PCG64 from astropy.io import fits @@ -142,9 +143,9 @@ class Chip(FocalPlane): return rowID, colID def _getSurveyType(self): - if self.filter_type in ["GI", "GV", "GU"]: + if self.filter_type in _util.SPEC_FILTERS: return "spectroscopic" - elif self.filter_type in ["NUV", "u", "g", 'r', 'i', 'z', 'y', 'FGS']: + elif self.filter_type in _util.PHOT_FILTERS: return "photometric" # elif self.filter_type in ["FGS"]: # return "FGS" @@ -190,7 +191,7 @@ class Chip(FocalPlane): def getChipFilter(self, chipID=None): """Return the filter index and type for a given chip #(chipID) """ - filter_type_list = ["NUV","u", "g", "r", "i","z","y","GU", "GV", "GI", "FGS"] + filter_type_list = _util.ALL_FILTERS if chipID == None: chipID = self.chipID @@ -228,7 +229,7 @@ class Chip(FocalPlane): for i in range(4): x = xcen + sign_x[i] * self.npix_x / 2. y = ycen + sign_y[i] * self.npix_y / 2. - x, y = rotate_conterclockwise(x0=xcen, y0=ycen, x=x, y=y, angle=self.rotate_angle) + x, y = _util.rotate_conterclockwise(x0=xcen, y0=ycen, x=x, y=y, angle=self.rotate_angle) xmin, xmax = min(xmin, x), max(xmax, x) ymin, ymax = min(ymin, y), max(ymax, y) return galsim.BoundsD(xmin, xmax, ymin, ymax) @@ -267,7 +268,7 @@ class Chip(FocalPlane): noise = self.dark_noise * exptime + self.read_noise**2 return noise - def addEffects(self, config, img, chip_output, filt, ra_cen, dec_cen, img_rot, exptime=150., pointing_ID=0, timestamp_obs=1621915200, pointing_type='MS', sky_map=None, tel=None, logger=None): + def addEffects(self, config, img, chip_output, filt, ra_cen, dec_cen, img_rot, exptime=150., pointing_ID=0, timestamp_obs=1621915200, pointing_type='SCI', sky_map=None, tel=None, logger=None): # Set random seeds SeedGainNonuni=int(config["random_seeds"]["seed_gainNonUniform"]) SeedBiasNonuni=int(config["random_seeds"]["seed_biasNonUniform"]) @@ -325,7 +326,7 @@ class Chip(FocalPlane): # img.addNoise(poisson_noise) # Add cosmic-rays - if config["ins_effects"]["cosmic_ray"] == True and pointing_type=='MS': + if config["ins_effects"]["cosmic_ray"] == True and pointing_type=='SCI': chip_utils.log_info(msg=" Adding Cosmic-Ray", logger=self.logger) img, crmap_gsimg, cr_event_num = chip_utils.add_cosmic_rays(img=img, chip=self, exptime=exptime, seed=SeedCosmicRay+pointing_ID*30+self.chipID) @@ -339,6 +340,8 @@ class Chip(FocalPlane): pointing_ID=pointing_ID, output_dir=chip_output.subdir, exptime=exptime, + project_cycle=config["project_cycle"], + run_counter=config["run_counter"], timestamp=timestamp_obs) del crmap_gsimg @@ -490,6 +493,8 @@ class Chip(FocalPlane): pointing_ID=pointing_ID, output_dir=chip_output.subdir, exptime=0.0, + project_cycle=config["project_cycle"], + run_counter=config["run_counter"], timestamp=timestamp_obs) del BiasCombImg @@ -590,6 +595,8 @@ class Chip(FocalPlane): pointing_ID=pointing_ID, output_dir=chip_output.subdir, exptime=self.flat_exptime, + project_cycle=config["project_cycle"], + run_counter=config["run_counter"], timestamp=timestamp_obs) del FlatCombImg, FlatSingle, prnu_img @@ -643,6 +650,8 @@ class Chip(FocalPlane): pointing_ID=pointing_ID, output_dir=chip_output.subdir, exptime=self.dark_exptime, + project_cycle=config["project_cycle"], + run_counter=config["run_counter"], timestamp=timestamp_obs) del crmap_gsimg @@ -709,6 +718,8 @@ class Chip(FocalPlane): pointing_ID=pointing_ID, output_dir=chip_output.subdir, exptime=self.dark_exptime, + project_cycle=config["project_cycle"], + run_counter=config["run_counter"], timestamp = timestamp_obs) del DarkCombImg # img = galsim.ImageUS(img) diff --git a/ObservationSim/Instrument/Chip/ChipUtils.py b/ObservationSim/Instrument/Chip/ChipUtils.py index d8e9a0aaf4cfb895f1e173599a2015bd95688a93..fae357054bd316065b5d9ed6c584bf5b663c5cfc 100644 --- a/ObservationSim/Instrument/Chip/ChipUtils.py +++ b/ObservationSim/Instrument/Chip/ChipUtils.py @@ -37,7 +37,7 @@ def getChipSLSConf(chipID): if chipID == 30: confFile = ['CSST_GI8.conf', 'CSST_GI7.conf'] return confFile -def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime=150., timestamp = 1621915200): +def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime=150., project_cycle=6, run_counter=0, timestamp = 1621915200): datetime_obs = datetime.utcfromtimestamp(timestamp) date_obs = datetime_obs.strftime("%y%m%d") time_obs = datetime_obs.strftime("%H%M%S") @@ -52,6 +52,8 @@ def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime time_obs=time_obs, im_type = im_type, exptime=exptime, + project_cycle=project_cycle, + run_counter=run_counter, chip_name=str(chip.chipID).rjust(2, '0') ) h_ext = generateExtensionHeader( @@ -75,7 +77,7 @@ def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime readoutTime = chip.readout_time) return h_prim, h_ext -def outputCal(chip, img, ra_cen, dec_cen, img_rot, im_type, pointing_ID, output_dir, exptime=150., timestamp = 1621915200): +def outputCal(chip, img, ra_cen, dec_cen, img_rot, im_type, pointing_ID, output_dir, exptime=150., project_cycle=6, run_counter=0, timestamp = 1621915200): h_prim, h_ext = generateHeader( chip=chip, ra_cen=ra_cen, @@ -84,6 +86,8 @@ def outputCal(chip, img, ra_cen, dec_cen, img_rot, im_type, pointing_ID, output_ im_type=im_type, pointing_ID=pointing_ID, exptime=exptime, + project_cycle=project_cycle, + run_counter=run_counter, timestamp=timestamp) hdu1 = fits.PrimaryHDU(header=h_prim) hdu1.add_checksum() diff --git a/ObservationSim/Instrument/Filter.py b/ObservationSim/Instrument/Filter.py index 16ec892191314bbe92637be69a549530069ad439..efc58694b2a75b6016b4653689be89bf24fda151 100755 --- a/ObservationSim/Instrument/Filter.py +++ b/ObservationSim/Instrument/Filter.py @@ -4,7 +4,7 @@ import os import numpy as np import gc -from ObservationSim.Instrument._util import photonEnergy, calculateLimitMag +import ObservationSim.Instrument._util as _util from ObservationSim.Instrument.FilterParam import FilterParam from ObservationSim.Straylight import Straylight @@ -26,7 +26,7 @@ class Filter(object): self.survey_type = self._getSurveyType() def _getSurveyType(self): - if self.filter_type in ["GI", "GV", "GU"]: + if self.filter_type in _util.SPEC_FILTERS: return "spectroscopic" else: return "photometric" @@ -106,20 +106,20 @@ class Filter(object): return bandpass_full, bandpass_sub_list def getPhotonE(self): - return photonEnergy(self.effective_wavelength) + return _util.photonEnergy(self.effective_wavelength) def getSkyNoise(self, exptime, gain=1.): return self.sky_background * exptime / gain def setFilterStrayLightPixel(self,jtime = 2460843., sat_pos = np.array([0,0,0]), pointing_radec = np.array([0,0]), sun_pos = np.array([0,0,0])): sl = Straylight(jtime=jtime, sat_pos=sat_pos, pointing_radec=pointing_radec,sun_pos=sun_pos) - if self.filter_type in ["GU","GV","GI"]: + if self.filter_type in _util.SPEC_FILTERS: s_pix, spec = sl.calculateStrayLightGrating(grating = self.filter_type.upper()) if s_pix>0.8: s_pix = 0.8 self.sky_background = s_pix self.zodical_spec = spec - elif self.filter_type.lower() in ["nuv","u","g","r","i","z","y"]: + elif self.filter_type.lower() in [x.lower for x in _util.PHOT_FILTERS]: s_pix = sl.calculateStrayLightFilter(filter=self.filter_type.lower()) if s_pix>1: s_pix = 1 @@ -130,7 +130,7 @@ class Filter(object): gc.collect() def update_limit_saturation_mags(self, exptime=150., psf_fwhm=0.1969, skyFn='sky_emiss_hubble_50_50_A.dat', chip=None): - if self.filter_type in ["GI", "GV", "GU"]: + if self.filter_type in _util.SPEC_FILTERS: return if chip is not None: pix_scale = chip.pix_scale @@ -144,6 +144,6 @@ class Filter(object): full_well = 90000 throughput_file = self.filter_type.lower() + '_throughput.txt' - self.mag_limiting, self.mag_saturation = calculateLimitMag(psf_fwhm=psf_fwhm, pixelSize=pix_scale, throughputFn=throughput_file, readout=5.0, skyFn=skyFn, darknoise=dark_noise, exTime=exptime, fw=full_well) + self.mag_limiting, self.mag_saturation = _util.calculateLimitMag(psf_fwhm=psf_fwhm, pixelSize=pix_scale, throughputFn=throughput_file, readout=5.0, skyFn=skyFn, darknoise=dark_noise, exTime=exptime, fw=full_well) print("for filter %s: mag_limiting: %.3f, mag_saturation: %.3f"%(self.filter_type, self.mag_limiting, self.mag_saturation)) diff --git a/ObservationSim/Instrument/_util.py b/ObservationSim/Instrument/_util.py index f92849596f32360cfe0b8c5384ea883e5a193f22..58d153ccaa04160f776fb0a1752a0a3db9329d17 100755 --- a/ObservationSim/Instrument/_util.py +++ b/ObservationSim/Instrument/_util.py @@ -14,6 +14,10 @@ VC_A = 2.99792458e+18 # speed of light: A/s VC_M = 2.99792458e+8 # speed of light: m/s H_PLANK = 6.626196e-27 # Plank constant: erg s +ALL_FILTERS = ["NUV","u", "g", "r", "i","z","y","GU", "GV", "GI", "FGS"] +PHOT_FILTERS = ["NUV", "u", "g", 'r', 'i', 'z', 'y', 'FGS'] +SPEC_FILTERS = ["GI", "GV", "GU"] + def rotate_conterclockwise(x0, y0, x, y, angle): """ Rotate a point counterclockwise by a given angle around a given origin. diff --git a/ObservationSim/MockObject/MockObject.py b/ObservationSim/MockObject/MockObject.py index 654cb720188cd71a1b98e541cac26e866dec2160..ce6e3ba62a9148350610ed64b7faeab19611a79f 100755 --- a/ObservationSim/MockObject/MockObject.py +++ b/ObservationSim/MockObject/MockObject.py @@ -150,9 +150,10 @@ class MockObject(object): # Get PSF model psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold) - star = galsim.DeltaFunction(gsparams=gsp) - star = star.withFlux(nphotons) - star = galsim.Convolve(psf, star) + # star = galsim.DeltaFunction(gsparams=gsp) + # star = star.withFlux(nphotons) + # star = galsim.Convolve(psf, star) + star = psf.withFlux(nphotons) stamp = star.drawImage(wcs=chip_wcs_local, offset=offset) if np.sum(np.isnan(stamp.array)) > 0: diff --git a/ObservationSim/ObservationSim.py b/ObservationSim/ObservationSim.py index f3001ac1b4c117dc883ae227a11088892c77d674..e35d700886658b13b415f2910d95bbd17f2c0489 100755 --- a/ObservationSim/ObservationSim.py +++ b/ObservationSim/ObservationSim.py @@ -143,7 +143,7 @@ class Observation(object): sky_map = sky_map+filt.sky_background del flat_normal - if pointing.pointing_type == 'MS': + if pointing.pointing_type == 'SCI': # Load catalogues and templates self.cat = self.Catalog(config=self.config, chip=chip, pointing=pointing, cat_dir=cat_dir, sed_dir=sed_dir, chip_output=chip_output, filt=filt) chip_output.create_output_file() @@ -152,7 +152,7 @@ class Observation(object): for ifilt in range(len(self.all_filter)): temp_filter = self.all_filter[ifilt] # Update the limiting magnitude using exposure time in pointing - temp_filter.update_limit_saturation_mags(exptime=pointing.exp_time, chip=chip) + temp_filter.update_limit_saturation_mags(exptime=pointing.get_full_depth_exptime(temp_filter.filter_type), chip=chip) # Select cutting band filter for saturation/limiting magnitude if temp_filter.filter_type.lower() == self.config["obs_setting"]["cut_in_band"].lower(): @@ -346,7 +346,7 @@ class Observation(object): sky_map=sky_map, tel = self.tel, logger=chip_output.logger) - if pointing.pointing_type == 'MS': + if pointing.pointing_type == 'SCI': datetime_obs = datetime.utcfromtimestamp(pointing.timestamp) date_obs = datetime_obs.strftime("%y%m%d") time_obs = datetime_obs.strftime("%H%M%S") @@ -363,6 +363,8 @@ class Observation(object): im_type='SCI', sat_pos=[pointing.sat_x, pointing.sat_y, pointing.sat_z], sat_vel=[pointing.sat_vx, pointing.sat_vy, pointing.sat_vz], + project_cycle=self.config["project_cycle"], + run_counter=self.config["run_counter"], chip_name=str(chip.chipID).rjust(2, '0')) h_ext = generateExtensionHeader( chip=chip, diff --git a/ObservationSim/_util.py b/ObservationSim/_util.py index 9f12f5d2c03feea2fba56cb2ad6e7207d08a7167..b1de8e2aee6a251fa0c69f8de60c90e4a4ca0b94 100755 --- a/ObservationSim/_util.py +++ b/ObservationSim/_util.py @@ -77,7 +77,7 @@ def generate_pointing_list(config, pointing_filename=None, data_dir=None): img_pa=config["obs_setting"]["image_rot"], timestamp=t, exp_time=exp_time, - pointing_type='MS' + pointing_type='SCI' ) t += delta_t * 60. pointing_list.append(pointing) diff --git a/config/config_C6.yaml b/config/config_C6.yaml index c130e59aee1b6bfa299f5ce6d2d5807bd86eff46..1bb2cc71c060f0c6fb345ca2f7340c090ce1b83d 100644 --- a/config/config_C6.yaml +++ b/config/config_C6.yaml @@ -9,9 +9,12 @@ # Base diretories and naming setup # Can add some of the command-line arguments here as well; # OK to pass either way or both, as long as they are consistent -work_dir: "/share/home/fangyuedong/csst-simulation/workplace/" +work_dir: "/share/home/fangyuedong/new_sim/workplace/" +# work_dir: "/share/C6_new_sim_2sq" data_dir: "/share/simudata/CSSOSDataProductsSims/data/" -run_name: "profile_C6" +run_name: "C6_new_sim_2sq_run1" +project_cycle: 6 +run_counter: 1 # Whether to use MPI run_option: @@ -44,7 +47,7 @@ catalog_options: AGN_SED_WAVE: "wave_ross13.npy" # Only simulate stars? - star_only: NO + star_only: YES # Only simulate galaxies? galaxy_only: NO @@ -112,7 +115,8 @@ obs_setting: cut_in_band: "z" # saturation magnitude margin - mag_sat_margin: -2.5 + # mag_sat_margin: -2.5 + mag_sat_margin: -15. # limiting magnitude margin mag_lim_margin: +1.0 diff --git a/profile_C6.sh b/profile_C6.sh index e018b7cbe45f87580a9fedf90ac62f332cbb9531..c7d03048dc0c4b4f85238f79d3c8e8d1f88e4710 100755 --- a/profile_C6.sh +++ b/profile_C6.sh @@ -3,17 +3,22 @@ date python -m cProfile -o C6_profiler_test.pstats /share/home/fangyuedong/new_sim/csst-simulation/run_sim.py \ - --config_file config_50sqdeg.yaml \ - --catalog C6_50sqdeg \ + --config_file config_C6.yaml \ + --catalog C6_Catalog \ -c /share/home/fangyuedong/new_sim/csst-simulation/config + + # --config_file config_test_new_sim.yaml \ + # --catalog New_sim_Test \ + # -c /share/home/fangyuedong/new_sim/csst-simulation/config + + # --config_file config_50sqdeg.yaml \ + # --catalog C6_50sqdeg \ + # -c /share/home/fangyuedong/new_sim/csst-simulation/config + # --config_file config_fgs.yaml \ # --catalog FGS_Catalog \ # -c /share/home/fangyuedong/csst-simulation/config - # --config_file config_C6.yaml \ - # --catalog C6_Catalog \ - # -c /share/home/fangyuedong/csst-simulation/config - # --config_file test_fd_C6.yaml \ # --catalog fd_test_C6 \ # --config_file config_C6_test_wcs.yaml \ diff --git a/run_C6.pbs b/run_C6.pbs index 2dca4572c6e1a6aa3946e94c2d1de621c423bc16..520645f4297e34f23b024f67f7e15ae81c9654f5 100755 --- a/run_C6.pbs +++ b/run_C6.pbs @@ -8,16 +8,17 @@ cd $PBS_O_WORKDIR -NP=96 -hostfile=wcl-1,wcl-2 +NP=384 +hostfile=wcl-1,wcl-2,wcl-3,wcl-4,wcl-5,wcl-6 date mpirun --oversubscribe -H $hostfile -np $NP python /share/home/fangyuedong/new_sim/csst-simulation/run_sim.py \ - --config_file config_50sqdeg.yaml \ - --catalog C6_50sqdeg \ + --config_file config_C6.yaml \ + --catalog C6_Catalog \ -c /share/home/fangyuedong/new_sim/csst-simulation/config - # --config_file config_C6.yaml \ - # --catalog C6_Catalog \ - # -c /share/home/fangyuedong/csst-simulation/config + + # --config_file config_50sqdeg.yaml \ + # --catalog C6_50sqdeg \ + # -c /share/home/fangyuedong/new_sim/csst-simulation/config diff --git a/run_sim.py b/run_sim.py index 4cb70b496070d2aad22d93b5078341f605c27a8c..b0a34280fbb9fb1460b9312d622305c5a7ed1d41 100755 --- a/run_sim.py +++ b/run_sim.py @@ -58,6 +58,10 @@ def run_sim(): config["obs_setting"]["mag_sat_margin"] = -2.5 if "mag_lim_margin" not in config["obs_setting"]: config["obs_setting"]["mag_lim_margin"] = 1.0 + if "project_cycle" not in config: + config["project_cycle"] = 6 + if "run_counter" not in config: + config["run_counter"] = 0 # Generate lists pointings based on the input pointing list (or default # pointing RA, DEC) and "config["obs_setting"]["run_pointings"]". diff --git a/setup.py b/setup.py index b0a56964817438f6c4951abf4292610ed303bd28..8ac92d60a907f8cf753cddf003f555660fb60788 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ extensions = [ df_module = [CTypes('ObservationSim.Instrument.Chip.lib_bf.libmoduleBF', ['ObservationSim/Instrument/Chip/lib_bf/diffusion_X1.c', 'ObservationSim/Instrument/Chip/lib_bf/nrutil.c'], - include_dirs=['ObservationSim/Instrument/Chip/lib_df_bf/', '/usr/include'] + include_dirs=['ObservationSim/Instrument/Chip/lib_bf/', '/usr/include'] )]