Skip to content

Commit

Permalink
Merge pull request #69 from lincc-frameworks/gmerz/refactor
Browse files Browse the repository at this point in the history
remove comments from flattening code
  • Loading branch information
grantmerz authored Nov 27, 2023
2 parents 8814c21 + 6eab4d9 commit ca09b6a
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions src/deepdisc/data_format/flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
from detectron2.utils.logger import setup_logger
setup_logger()

# import some common libraries
import numpy as np
import os, json, cv2, random
import deepdisc
from deepdisc.data_format.image_readers import DC2ImageReader

#PATH = deepdisc.__path__[0]

def flatten_dc2(ddicts):
"""Reads in large cutouts and creates postage stamp images centered on individual objects
Expand Down Expand Up @@ -54,16 +52,6 @@ def flatten_dc2(ddicts):

bxnew = x-(x+w//2 - 64)
bynew = y-(y+h//2 - 64)
#base=filename.split('.')[0].split('/')[-1]
#dirpath = '/home/g4merz/DC2/nersc_data/scarlet_data'
#fn=os.path.join(dirpath,base)+'.npy'

#print(filename.split('.fits')[0])
#base=os.path.join(os.path.dirname(os.path.dirname(PATH)),filename.split('.fits')[0])
#fn = base+'.npy'


#fn = get_test_image_path(d)

image = image_reader(filename)
image = np.transpose(image, axes=(2, 0, 1))
Expand All @@ -82,34 +70,13 @@ def flatten_dc2(ddicts):

flattened_data = []
for image,metadata in zip(images,metadatas):
#flatdat = np.concatenate((image,metadat.iloc[i].values))
flatdat = np.concatenate((image,metadata))
flattened_data.append(flatdat)


return flattened_data


def get_test_image_path(d):
"""Function to get an image filepath based on the "filepath" key in a metadata dict
Parameters
----------
d : dict
The metadata dictionary
Returns
-------
fn : str
The filepath to the stored image. Ideally, this should just return the "filename" key,
but if the user moves the images around or saves in a different format,
it can save the time to rename those keys in the metadata dictionaries
"""
filename= d[f"filename"]
base=os.path.join(os.path.dirname(os.path.dirname(PATH)),filename.split('.fits')[0])
fn = base+'.npy'
return fn




Expand Down

0 comments on commit ca09b6a

Please sign in to comment.