-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #380 from LSSTDESC/doc-file-types
Documentation Update
- Loading branch information
Showing
61 changed files
with
1,810 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import h5py | ||
import tabulate | ||
import sys | ||
|
||
class DescriptionGenerator: | ||
def __init__(self): | ||
self.rows = [] | ||
|
||
def __call__(self, name, obj): | ||
if not isinstance(obj, h5py.Dataset): | ||
return | ||
bits = name.split('/') | ||
groups = bits[:-1] | ||
name = bits[-1] | ||
kind = f"{obj.ndim}D {obj.dtype}" | ||
self.rows.append([groups, name, kind]) | ||
|
||
def to_table(self): | ||
groups = [row[0] for row in self.rows] | ||
ngroup_max = max(len(group) for group in groups) | ||
headers = ["Group"] + [""] * (ngroup_max - 1) + ["Name", "Kind", "Meaning"] | ||
rows = [] | ||
for row in self.rows: | ||
groups = row[0] + [""] * (ngroup_max - len(row[0])) | ||
name = row[1] | ||
kind = row[2] | ||
meaning = "" | ||
rows.append(groups + [name, kind, meaning]) | ||
return tabulate.tabulate(rows, headers=headers, tablefmt='rst') | ||
|
||
|
||
|
||
def describe_file(filename, outfile): | ||
with h5py.File(filename) as f: | ||
gen = DescriptionGenerator() | ||
f.visititems(gen) | ||
outfile.write(gen.to_table()) | ||
|
||
files = { | ||
"PhotometryCatalog": ("data/example/inputs/photometry_catalog.hdf5", "photometry"), | ||
"MetacalShearCatalog": ("data/example/inputs/shear_catalog.hdf5", "metacal"), | ||
"LensfitShearCatalog": ("data/example/inputs/lensfit_shear_catalog.hdf5", "lensfit"), | ||
"MetadetectShearCatalog": ("data/example/inputs/metadetect_shear_catalog.hdf5", "metadetect"), | ||
"StarCatalog": ("data/example/inputs/star_catalog.hdf5", "stars"), | ||
"TomographyCatalog": ("data/example/outputs_metadetect/shear_tomography_catalog.hdf5", "tomography"), | ||
"BinnedCatalog": ("data/example/outputs_metadetect/binned_lens_catalog.hdf5", "binned"), | ||
"RandomsCatalog": ("data/example/outputs_metadetect/random_cats.hdf5", "randoms"), | ||
"MapsFile": ("data/example/outputs_metadetect/lens_maps.hdf5", "maps"), | ||
"MetaData": ("data/example/outputs_metadetect/tracer_metadata.hdf5", "metadata"), | ||
} | ||
|
||
if __name__ == "__main__": | ||
if sys.argv[1] == "all": | ||
for name, (filename, outfile) in files.items(): | ||
outpath = "docs/src/file_details/" + outfile + ".rst" | ||
with open(outpath, "w") as f: | ||
f.write(f"## {outfile.capitalize()}\n\n") | ||
describe_file(filename, f) | ||
f.write("\n\n\n") | ||
else: | ||
describe_file(sys.argv[1], sys.stdout) | ||
sys.stdout.write("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import ceci | ||
|
||
pipeline_files = [ | ||
"examples/2.2i/pipeline.yml", | ||
"examples/buzzard/pipeline.yml", | ||
"examples/clmm/pipeline.yml", | ||
"examples/cosmodc2/pipeline.yml", | ||
"examples/desy1/pipeline.yml", | ||
"examples/desy3/pipeline.yml", | ||
"examples/dp0.2/pipeline.yml", | ||
"examples/kids-1000/pipeline.yml", | ||
"examples/lensfit/pipeline.yml", | ||
"examples/lognormal/pipeline.yml", | ||
"examples/metacal/pipeline.yml", | ||
"examples/metadetect/pipeline.yml", | ||
"examples/metadetect_source_only/pipeline.yml", | ||
"examples/mock_shear/pipeline.yml", | ||
"examples/redmagic/pipeline.yml", | ||
"examples/skysim/pipeline.yml", | ||
] | ||
|
||
def get_tags(pipeline_file): | ||
tags = set() | ||
|
||
pipe_config = ceci.Pipeline.build_config(pipeline_file, dry_run=True) | ||
|
||
with ceci.prepare_for_pipeline(pipe_config) as pipeline: | ||
p = ceci.Pipeline.create(pipe_config) | ||
|
||
# First pass, get the classes for all the stages | ||
stage_classes = [] | ||
for stage_name in p.stage_names: | ||
sec = p.stage_execution_config[stage_name] | ||
stage_classes.append(sec.build_stage_class()) | ||
|
||
stage_aliases = sec.aliases | ||
stage_class = sec.stage_class | ||
for tag,ftype in stage_class.outputs: | ||
aliased_tag = stage_aliases.get(tag, tag) | ||
if ftype.suffix is not None: | ||
tags.add((ftype.suffix, aliased_tag)) | ||
# if ftype.suffix is None: | ||
# print("NONE TAG TYPE:", stage_name, pipeline_file, stage_class) | ||
for tag, ftype in stage_class.inputs: | ||
aliased_tag = stage_aliases.get(tag, tag) | ||
if ftype.suffix is not None: | ||
tags.add((ftype.suffix, aliased_tag)) | ||
# if ftype.suffix is None: | ||
# print("NONE TAG TYPE:", stage_name, pipeline_file, stage_class) | ||
|
||
return tags | ||
|
||
|
||
|
||
|
||
def main(): | ||
tags = set() | ||
for pipeline_file in pipeline_files: | ||
try: | ||
tags.update(get_tags(pipeline_file)) | ||
except ceci.errors.StageNotFound: | ||
print(f"Error: {pipeline_file} old") | ||
continue | ||
except ValueError: | ||
print(f"Error: {pipeline_file} broken") | ||
continue | ||
# print(tags) | ||
for tag in sorted(tags): | ||
print(tag) | ||
|
||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.