Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rknop committed Oct 11, 2024
1 parent d36cb6b commit b4349d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 82 deletions.
75 changes: 0 additions & 75 deletions pipeline/ref_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,81 +386,6 @@ def setup_provenances(self, session=None):
self.ref_prov.insert_if_needed()


# ======================================================================

# def parse_arguments(self, *args, **kwargs):
# """Figure out if the input parameters are given as coordinates or as target + section ID pairs.

# Possible combinations:
# - float + float + string: interpreted as RA/Dec in degrees
# - str + str: try to interpret as sexagesimal (RA as hours, Dec as degrees)
# if it fails, will interpret as target + section ID
# # TODO: can we identify a reference with only a target/field ID without a section ID? Issue #320
# In addition to the first two arguments, can also supply a filter name as a string
# and can provide a session object as an argument (in any position) to be used and kept open
# for the entire run. If not given a session, will open a new one and close it when done using it internally.

# Alternatively, can provide named arguments with the same combinations for either
# (ra, dec) or (target, section_id) and filter.

# Returns
# -------
# session: sqlalchemy.orm.session.Session object or None
# The session object, if it was passed in as a positional argument.
# If not given, the ref maker will just open and close sessions internally
# when needed.
# """
# self.ra = None
# self.dec = None
# self.target = None
# self.section_id = None
# self.filter = None

# args, kwargs, session = parse_session(*args, **kwargs) # first pick out any sessions

# if len(args) == 3:
# if not isinstance(args[2], str):
# raise ValueError('Third argument must be a string, the filter name!')
# self.filter = args[2]
# args = args[:2] # remove the last one

# if len(args) == 2:
# if isinstance(args[0], (float, int, np.number)) and isinstance(args[1], (float, int, np.number)):
# self.ra = float(args[0])
# self.dec = float(args[1])
# if isinstance(args[0], str) and isinstance(args[1], str):
# try:
# self.ra = parse_sexigesimal_degrees(args[0], hours=True)
# self.dec = parse_sexigesimal_degrees(args[1], hours=False)
# except ValueError:
# self.target, self.section_id = args[0], args[1]
# elif len(args) == 0: # parse kwargs instead!
# if 'ra' in kwargs and 'dec' in kwargs:
# self.ra = kwargs.pop('ra')
# if isinstance(self.ra, str):
# self.ra = parse_sexigesimal_degrees(self.ra, hours=True)

# self.dec = kwargs.pop('dec')
# if isinstance(self.dec, str):
# self.dec = parse_sexigesimal_degrees(self.dec, hours=False)

# elif 'target' in kwargs and 'section_id' in kwargs:
# self.target = kwargs.pop('target')
# self.section_id = kwargs.pop('section_id')
# else:
# raise ValueError('Cannot find ra/dec or target/section_id in any of the inputs! ')

# if 'filter' in kwargs:
# self.filter = kwargs.pop('filter')

# else:
# raise ValueError('Invalid number of arguments given to RefMaker.parse_arguments()')

# if self.filter is None:
# raise ValueError('No filter given to RefMaker.parse_arguments()!')

# return session

# ======================================================================

def _append_provenance_to_refset_if_appropriate( self, existing, session ):
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def decam_datastore(
decam_exposure,
'S3',
cache_dir=decam_cache_dir,
cache_base_name='007/c4d_20230702_080904_S3_r_Sci_PN4G4I',
cache_base_name='007/c4d_20230702_080904_S3_r_Sci_IDDLGQ',
overrides={ 'subtraction': { 'refset': 'test_refset_decam' } },
save_original_image=True,
provtag='decam_datastore'
Expand Down
12 changes: 6 additions & 6 deletions tests/pipeline/test_coaddition.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,18 @@ def test_coadd_partial_overlap_swarp( decam_four_offset_refs, decam_four_refs_al
# (I manually looked at the image and picked out a few spots)

# Check that the weight is higher in a region where two images actually overlapped
assert img.weight[ 550:640, 975:1140 ].mean() == pytest.approx( 0.0199, abs=0.0005 )
assert img.weight[ 690:770, 930:1050 ].mean() == pytest.approx( 0.0131, abs=0.0005 )
assert img.weight[ 550:640, 975:1140 ].mean() == pytest.approx( 0.020, abs=0.001 )
assert img.weight[ 690:770, 930:1050 ].mean() == pytest.approx( 0.013, abs=0.001 )

# Look at a spot with a star, and a nearby sky, in a place where there was only
# one image in the coadd
assert img.data[ 3217:3231, 479:491 ].sum() == pytest.approx( 82530., abs=25. )
assert img.data[ 3217:3231, 509:521 ].sum() == pytest.approx( 231., abs=25. )
assert img.data[ 3217:3231, 479:491 ].sum() == pytest.approx( 84485., abs=25. )
assert img.data[ 3217:3231, 509:521 ].sum() == pytest.approx( 210., abs=25. )

# Look at a spot with a galaxy and a nearby sky, in a place where there were
# two images in the sum
assert img.data[ 237:266, 978:988 ].sum() == pytest.approx( 7918., abs=10. )
assert img.data[ 237:266, 1008:1018 ].sum() == pytest.approx( 44., abs=10. )
assert img.data[ 237:266, 978:988 ].sum() == pytest.approx( 8088., abs=10. )
assert img.data[ 237:266, 1008:1018 ].sum() == pytest.approx( 53., abs=10. )

# This test is very slow, and also perhaps a bit much given that it downloads
# and swarps together 17 images. As such, put in two conditions to skip it;
Expand Down

0 comments on commit b4349d6

Please sign in to comment.