Skip to content

Commit

Permalink
Merge pull request #115 from lsst-epo/114-add-metadata-columns
Browse files Browse the repository at this point in the history
Added `metadata:` columns to manifest functions
  • Loading branch information
beckynevin authored Oct 7, 2024
2 parents d34cd49 + 01a0f24 commit 3ffa5ae
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ def make_manifest_with_calexp_images(
cutouts = []
# for each moment in time, create the calexp image
for i, idx in enumerate(idx_select):
if hasattr(sorted_sources, "diaObjectId") is False:
print("The column 'diaObjectId' is required to send data to the Zooniverse"
+ "for this notebook! Please query for your data again adding "
+ "'diaObjectId' and then rerun this cell.")
return
star_ra = sorted_sources["ra"][idx]
star_dec = sorted_sources["decl"][idx]
star_visitid = sorted_sources["visitId"][idx]
Expand All @@ -316,6 +321,8 @@ def make_manifest_with_calexp_images(
)
# and of the diaObjectId
figout_data["diaObjectId:image_" + str(i)] = str(star_id)
figout_data[f"metadata:diaObjectId_image_{str(i)}"] = str(star_id)

figout_data["filename"] = str(star_id) + "_" + str(star_ccdid) + ".png"
cutouts.append(figout_data)
return cutouts
Expand All @@ -324,6 +331,7 @@ def make_manifest_with_calexp_images(
def make_manifest_with_deepcoadd_images(results_table, butler, batch_dir):
# In-memory manifest file as an array of dicts
manifest = []
has_canonical_id = False

# Create directory if it does not already exist
if os.path.isdir(batch_dir) is False:
Expand All @@ -340,10 +348,6 @@ def make_manifest_with_deepcoadd_images(results_table, butler, batch_dir):
csv_row = {
# required column, do not change the column name
"filename": filename,
# required column, do not change the column name
"objectId": row.objectId,
# required column, do not change the column name
"objectIdType": "DIRECT",
# Add your desired columns:
"coord_ra": row.coord_ra,
"coord_dec": row.coord_dec,
Expand All @@ -352,8 +356,29 @@ def make_manifest_with_deepcoadd_images(results_table, butler, batch_dir):
"r_extendedness": row.r_extendedness,
"r_inputCount": row.r_inputCount,
}

# These columns are required in order to cross-match your completed
if hasattr(row, "objectId"):
has_canonical_id = True
csv_row["objectId"] = row.objectId
csv_row["metadata:objectId"] = row.objectId
csv_row["objectIdType"] = "DIRECT"
if hasattr(row, "diaObjectId"):
has_canonical_id = True
csv_row["diaObjectId"] = row.diaObjectId
csv_row["metadata:diaObjectId"] = row.diaObjectId
if "objectIdType" not in csv_row:
csv_row["objectIdType"] = "INDIRECT"

manifest.append(csv_row)
remove_figure(figout)

if has_canonical_id is False:
print("WARNING! You did not include either objectId or diaObjectId in your "
+ "manifest file dataset. These fields are used to cross-match the "
+ "completed classifications workflow data back to the original data. "
+ "Consider rerunning this cell after adding either objectId, "
+ "diaObjectId, or both.")
return manifest


Expand Down

0 comments on commit 3ffa5ae

Please sign in to comment.