Skip to content

Commit

Permalink
Removing formatting changes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
gmegh committed Apr 12, 2024
1 parent 98ab871 commit f4716b2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
18 changes: 16 additions & 2 deletions python/lsst/ts/imsim/closed_loop_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@

class ClosedLoopTask:
"""Initialization of the closed loop task class to
run the simulation with imSim.
"""
run the simulation with imSim."""

def __init__(self) -> None:
self.log = logging.getLogger(type(self).__name__)
Expand Down Expand Up @@ -109,6 +108,7 @@ def config_sky_sim(
ValueError
This instrument name is not supported.
"""

self.sky_sim = SkySim()
self.sky_sim.set_camera(cam_type)
if path_sky_file == "":
Expand Down Expand Up @@ -142,6 +142,7 @@ def _set_sky_sim_based_on_opd_field_pos(
ValueError
This instrument name is not supported.
"""

self.log.info(
"Use the default OPD field positions to be star positions. "
f"The star magnitude is chosen to be {star_mag}."
Expand Down Expand Up @@ -195,6 +196,7 @@ def config_ofc_calc(self, cam_type: CamType) -> None:
cam_type : lsst.ts.imsim.utils.CamType
Camera type.
"""

self.ofc_calc = OFC(OFCData(cam_type.value))
self.ofc_calc.ofc_data.zn_selected = np.arange(
self.ofc_calc.ofc_data.znmin, self.max_noll_index
Expand Down Expand Up @@ -230,6 +232,7 @@ def check_boresight(self, boresight: list[float]) -> None:
ValueError
The declination (Dec) should be in [-90, 90].
"""

ra, dec = boresight
if ra < 0 or ra > 360:
raise ValueError("The right ascension (RA) should be in [0, 360].")
Expand Down Expand Up @@ -257,6 +260,7 @@ def get_sensor_name_list_of_fields(self, cam_type: CamType) -> list[str]:
ValueError
This instrument name is not supported.
"""

camera = get_camera(cam_type)
detector_type = (
DetectorType.WAVEFRONT
Expand Down Expand Up @@ -289,6 +293,7 @@ def get_sensor_id_list_of_fields(self, cam_type: CamType) -> list[int]:
ValueError
This instrument name is not supported.
"""

camera = get_camera(cam_type)

detector_type = (
Expand Down Expand Up @@ -604,6 +609,7 @@ def _generate_images(
code will just default to sending it to stdout.
(The default is "".)
"""

# Generate the images
if imsim_config_pointer_file is None:
if cam_type == CamType.LsstCam:
Expand Down Expand Up @@ -750,6 +756,7 @@ def _calc_wf_err_from_img(
list[lsst.ts.imsim.utils.SensorWavefrontError]
List of SensorWavefrontError object.
"""

# Ingest images into butler gen3
self.ingest_data(butler_root_path=butler_root_path, cam_type=cam_type)

Expand Down Expand Up @@ -779,6 +786,7 @@ def _get_butler_inst_name(self, cam_type: CamType) -> str:
str
Suffix attached to "LSST" to specify instrument to butler.
"""

if cam_type in [CamType.LsstCam, CamType.LsstFamCam]:
butler_inst_name = "Cam"
elif cam_type == CamType.ComCam:
Expand Down Expand Up @@ -823,6 +831,7 @@ def run_wep(
List of SensorWavefrontError with the results of the wavefront
estimation pipeline for each sensor.
"""

butler_inst_name = self._get_butler_inst_name(cam_type)
if pipeline_file is None:
pipeline_yaml = f"{cam_type.value}Pipeline.yaml"
Expand Down Expand Up @@ -927,6 +936,7 @@ def write_wep_configuration(
wep_estimator : enum 'WepEstimator' in lsst.ts.wep.utility
Specify the method used to calculate Zernikes in ts_wep.
"""

butler_inst_name = self._get_butler_inst_name(cam_type)

# Remap reference filter
Expand Down Expand Up @@ -1147,6 +1157,7 @@ def generate_butler(self, butler_root_path: str, cam_type: CamType) -> None:
cam_type : lsst.ts.imsim.utils.CamType
Camera type.
"""

self.log.info(
f"Generating butler gen3 in {butler_root_path} for {cam_type.name}"
)
Expand Down Expand Up @@ -1248,6 +1259,7 @@ def erase_directory_content(self, target_dir: str) -> None:
target_dir : str
Target directory.
"""

for file_on in os.listdir(target_dir):
file_path = os.path.join(target_dir, file_on)
if os.path.isfile(file_path):
Expand All @@ -1269,6 +1281,7 @@ def set_default_parser(parser: ArgumentParser) -> ArgumentParser:
argparse.ArgumentParser
Updated parser.
"""

parser.add_argument(
"--inst",
type=str,
Expand Down Expand Up @@ -1393,6 +1406,7 @@ def set_img_parser(parser: ArgumentParser) -> ArgumentParser:
argparse.ArgumentParser
Updated parser.
"""

parser.add_argument(
"--boresight_deg",
type=float,
Expand Down
34 changes: 30 additions & 4 deletions python/lsst/ts/imsim/imsim_cmpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,34 @@
class ImsimCmpt:
"""Class to take configurations for each imsim component and
generate full imsim configuration files.
Attributes
----------
_output_dir : str
Output directory.
_output_img_dir : str
Output image directory.
opd_file_path : str
OPD file path.
opd_metr : lsst.ts.imsim.OpdMetrology
OPD metrology.
num_of_zk : int
Number of Zernikes.
num_of_dof : int
Number of degrees of freedom.
dof_in_um : numpy.ndarray
Degrees of freedom in microns.
"""

def __init__(self, num_of_zk: int) -> None:
"""Initialize the ImsimCmpt class.
Parameters
----------
num_of_zk : int
Number of Zernikes.
"""
# Output directories
self._output_dir = None
self._output_img_dir = None
Expand Down Expand Up @@ -161,11 +186,11 @@ def assemble_config_yaml(

config_sections = ["input", "gal", "image", "psf", "stamp", "output"]

with open(config_pointer_file) as f:
with open(config_pointer_file, "r") as f:
file_pointer_info = yaml.safe_load(f)
self._verify_pointer_file(file_pointer_info, config_sections)

with open(required_modules_file) as required_modules:
with open(required_modules_file, "r") as required_modules:
required_modules_text = required_modules.read()

# Assemble full configuration as text because of the
Expand All @@ -179,7 +204,7 @@ def assemble_config_yaml(
input_section_text = "input:\n"
for sub_section in ["atm_psf", "sky_model", "telescope", "vignetting"]:
with open(
file_pointer_info["input"][sub_section].format(**os.environ)
file_pointer_info["input"][sub_section].format(**os.environ), "r"
) as sub_file:
for line in sub_file.readlines():
input_section_text += " " + line
Expand All @@ -190,7 +215,7 @@ def assemble_config_yaml(
continue
else:
with open(
file_pointer_info[section_name].format(**os.environ)
file_pointer_info[section_name].format(**os.environ), "r"
) as section_file:
full_config_text += section_file.read() + "\n"
# Handle output specially since we need to add header info and OPD
Expand Down Expand Up @@ -422,6 +447,7 @@ def gen_instance_catalog(self, sky_sim: SkySim) -> str:
str
Text to write to instance catalog file.
"""

content = ""
content += self.gen_inst_cat_stars(sky_sim)
return content
Expand Down

0 comments on commit f4716b2

Please sign in to comment.