Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/source/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ Martin Kilbinger
- [Axel Guinot](https://github.com/aguinot) : Primary module developer, validation, performance and debugging
- [Martin Kilbinger](https://github.com/martinkilbinger) : Scientific lead, module developer and debugging

## Principal Contributors
## Contributors

- [Lucie Baumont](https://github.com/lbaumo) : Testing
- [Jérôme Bonnin](https://github.com/jerome-bonnin) : PSF module developer
- [Cail Daley](https://www.cosmostat.org/people/cail-daley) : Container development
- [Fabian Hervas Peters](https://www.cosmostat.org/people/former-members/fabian-hervas-peters) : Simulations, validation
- Marc Gentile : File IO, initial architecture
- Xavier Jimenez : External catalogue matching module developer
- [Mike Hudson](https://uwaterloo.ca/physics-astronomy/profile/mjhudson) : Further contributors
- Xavier Jimenez : External catalogue matching
- [François Lanusse](https://github.com/eiffl) : Further contributors
- [Tobias Liaudat](https://github.com/tobias-liaudat) : PSF module developer and validation
- [Austin Peel](https://github.com/austinpeel) : Validation
Expand Down
1 change: 0 additions & 1 deletion docs/source/pipeline_canfar.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ ln -s ..//unions_shapepipe_comprehensive_struct_2024_v1.6.c.hdf5 unions_shapepip

calibrate_comprehensive


### Create matched star catalogue

For diagnostics, a catalogue with multi-epoch shapes measured by ngmix matched with the validation star catalogue is used.
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies = [
"canfar",
"sf_tools",
"h5py",
"healsparse",
"skyproj",
]


Expand All @@ -33,6 +35,10 @@ lint = [
"black",
"isort"
]
plot = [
"skyproj",
"matplotlib"
]
release = [
"build",
"twine",
Expand All @@ -52,6 +58,12 @@ summary_run = "shapepipe.summary_run:main"
canfar_submit_job = "shapepipe.canfar_run:run_job"
canfar_monitor = "shapepipe.canfar_run:run_log"
canfar_monitor_log = "shapepipe.canfar_run:run_monitor_log"
get_ccd_with_psfs = "shapepipe.get_ccds_run:run_ccd_psf_handler"
download_headers = "shapepipe.coverage_run:run_download_headers"
extract_field_corners = "shapepipe.coverage_run:run_extract_corners"
build_coverage_map = "shapepipe.coverage_run:run_build_coverage"
plot_coverage_map = "shapepipe.coverage_run:run_plot_coverage"
coverage_pipeline = "shapepipe.coverage_run:run_pipeline"

[tool.pytest.ini_options]
addopts = "--verbose --cov=shapepipe"
Expand Down
180 changes: 19 additions & 161 deletions scripts/python/get_ccds_with_psf.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,192 +9,50 @@

"""


import sys
import numpy as np

from shapepipe.utilities import summary


def get_lines(fname):
"""Get Lines.

Return list of lines read from a text file.

Parameters
----------
fname: str
input file name

Returns:
list
IDs
from shapepipe.utilities.ccd_psf_handler import CcdPsfHandler

"""
IDs = []
with open(fname) as f:
lines = f.readlines()
for line in lines:
IDs.append(line.rstrip())

return IDs

def run_ccd_psf_handler(args=None):
"""Run CCD PSF Handler.

def get_exp_shdu_missing(patches):
"""Get Exp Shdu Missing.

Returns set of missing CCDs (single-exposure single-HDU IDs) from a list of patches.
Create instance and run the CCD PSF handler.

Parameters
----------
patches: list
input patches
args : list, optional
command line arguments

Returns
-------
set
missing CCD IDs
int
exit code

"""
exp_shdu_missing_all = set()

for patch in patches:

path_exp_shdu_missing = f"{patch}/summary/missing_job_32_all.txt"
exp_shdu_missing = get_lines(path_exp_shdu_missing)

print(f"Patch {patch}: Found {len(exp_shdu_missing)} missing ccds", end="; ")

exp_shdu_missing_all.update(exp_shdu_missing)

print(f"cumulative {len(exp_shdu_missing_all)} missing ccds")

print()

return exp_shdu_missing_all


def get_exp(patches):
"""Get Exp.

Return set of exposures from a list of patches.

Parameters
----------
patches: list
input patches

Returns
-------
set
exposure IDs

"""
exp_all = set()

for patch in patches:

path_exp = f"{patch}/exp_numbers.txt"
exp = get_lines(path_exp)

print(f"Patch {patch}: Found {len(exp)} exposures", end="; ")

exp_all.update(exp)

print(f"cumulative {len(exp_all)} exposures")
# Create instance
obj = CcdPsfHandler()

print()
return obj.run(args=args)

return exp_all

def main(argv=None):
"""Main.

def get_ccds_with_psf(patches, n_CCD=40):
"""Get CCDs With PSF.

Return set of CCDs from list of patches.
Main program.

Parameters
----------
patches: list
input patches
argv : list, optional
command line arguments

Returns
-------
set
CCD IDs
int
exit code

"""
# Get missing CCDs
print("=== get missing CCDs ===")
exp_shdu_missing_all = get_exp_shdu_missing(patches)

# Get all exposures used in tiles
print("=== get exposures ===")
exp_all = get_exp(patches)

# Turn exposures into exposure-single-HDU names (CCDs)
exp_shdu_all = summary.get_all_shdus(exp_all, n_CCD)

print(f"Found {len(exp_shdu_all)} CCDs")

return exp_shdu_all


def get_ccds_with_psf_method_2(patches, n_CCD=40):

for patch in patches:
directory = f"{patch}/exp_runs"

for entry in os.scandir(directory):
pass

def save(IDs, path):
"""Save.

Save list of IDs to text file.

Parameters
----------
IDs: set
input IDs

path: str
output file name

"""
with open(path, "w") as f_out:
for ID in IDs:
print(ID, file=f_out)

def main(argv):
"""Main.

Main program.

"""
version = "v1.5"

if version == "v1.4":
n_patch = 7
elif version == "v1.5":
n_patch = 8
else:
raise ValueError(f"Invalid version {version}")

patches = [f'P{x}' for x in np.arange(n_patch) + 1]

print(f"=== get_ccds_with_psf for version {version}, patches {patches} ===")

print("=== method 1: exp_list - missing === ")
exp_shdu_all = get_ccds_with_psf(patches)

save(exp_shdu_all, f"ccds_with_psf_{version}.txt")

#print("=== method 2: star cats === ")
#exp_shdu_all_method_2 = get_ccds_with_psf_method_2(patches)
#save(exp_shdu_all_method_2, f"ccds_with_psf_{version}_method_2.txt")

return 0
return run_ccd_psf_handler(args=argv)


if __name__ == "__main__":
Expand Down
Loading