From 33113c27dd0737c9a92dd6790d41b2efce1b026c Mon Sep 17 00:00:00 2001 From: Marcus Hughes Date: Wed, 11 Dec 2024 02:29:24 -0700 Subject: [PATCH] Accelerate and make more realistic (#101) * allow changing the parameters of simulation rate * decrease clear star brightness * deep copy the original wcs * brighten clear stars --- simpunch/flow.py | 10 +++++++--- simpunch/level0.py | 3 ++- simpunch/level2.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/simpunch/flow.py b/simpunch/flow.py index 2aabb9e..b2944a1 100644 --- a/simpunch/flow.py +++ b/simpunch/flow.py @@ -27,13 +27,15 @@ def generate_flow(gamera_directory: str, transient_probability: float = 0.03, shift_pointing: bool = False, generate_new: bool = True, - update_database: bool = True) -> None: + generate_full_day: bool = False, + update_database: bool = True, + surrounding_cadence: float = 1.0) -> None: """Generate all the products in the reverse pipeline.""" if start_time is None: start_time = datetime.now() # noqa: DTZ005 if generate_new: - time_delta = timedelta(days=0.1) + time_delta = timedelta(days=surrounding_cadence) files_tb = sorted(glob.glob(gamera_directory + "/synthetic_cme/*_TB.fits")) files_pb = sorted(glob.glob(gamera_directory + "/synthetic_cme/*_PB.fits")) @@ -45,7 +47,9 @@ def generate_flow(gamera_directory: str, for td in np.linspace(1, 30, int(timedelta(days=30)/time_delta))] generate_l3_all_fixed(gamera_directory, output_directory, next_month, files_pb[-1], files_tb[-1]) - generate_l3_all(gamera_directory, output_directory, start_time, num_repeats=num_repeats) + if generate_full_day: + generate_l3_all(gamera_directory, output_directory, start_time, num_repeats=num_repeats) + generate_l2_all(gamera_directory, output_directory) generate_l1_all(gamera_directory, output_directory) generate_l0_all(gamera_directory, diff --git a/simpunch/level0.py b/simpunch/level0.py index 78ba644..131f502 100644 --- a/simpunch/level0.py +++ b/simpunch/level0.py @@ -1,4 +1,5 @@ """Generate synthetic level 0 data.""" +import copy import glob import os from pathlib import Path @@ -95,7 +96,7 @@ def starfield_misalignment(input_data: NDCube, cr_offset_scale: float = 0.1, pc_offset_scale: float = 0.1) -> NDCube: """Offset the pointing in an image to simulate spacecraft uncertainty.""" - original_wcs = input_data.wcs.copy() + original_wcs = copy.deepcopy(input_data.wcs) cr_offsets = np.random.normal(0, cr_offset_scale, 2) input_data.wcs.wcs.crval = input_data.wcs.wcs.crval + cr_offsets diff --git a/simpunch/level2.py b/simpunch/level2.py index 72a9521..1aefe3a 100644 --- a/simpunch/level2.py +++ b/simpunch/level2.py @@ -238,7 +238,7 @@ def add_starfield_clear(input_data: NDCube) -> NDCube: input_data.data.shape) starfield, stars = generate_starfield(wcs_stellar_input, input_data.data[:, :].shape, - flux_set=100*2.0384547E-9, + flux_set=30*2.0384547E-9, fwhm=3, dimmest_magnitude=12, noise_mean=None, noise_std=None)