Skip to content

Commit

Permalink
Working on updating tests to use a DECam ELAIS-E1 field in place of a…
Browse files Browse the repository at this point in the history
… DECaPS-West field previously used
  • Loading branch information
rknop committed Jun 26, 2024
1 parent 914cfa7 commit 9e3687f
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 292 deletions.
2 changes: 1 addition & 1 deletion models/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ def overscan_sections( self, header ):
list of dicts; each element has fields
'secname': str,
'biassec': { 'x0': int, 'x1': int, 'y0': int, 'y1': int },
'datasec': { 'x0': int, 'x1': int, 'y0': int, 'y1': int }
'datasec': { 'x0': int, 'x1': int, 'y0': int, 'y1': int },
Secname is some subsection identifier, which is instrument
specific. By default, it will be 'A' or 'B'. Sections are in
C-coordinates (0-offset), using the numpy standard (i.e. x1 is
Expand Down
2 changes: 1 addition & 1 deletion pipeline/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def run( self, *args, **kwargs ):

if image._data is None: # in case we skip all preprocessing steps
image.data = image.raw_data

# the image keeps track of the steps already done to it in image.preproc_bitflag,
# which is translated into a list of keywords when calling image.preprocessing_done
# this includes the things that already were applied in the exposure
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def conductor_config_for_decam_pull( conductor_connector, decam_raw_origin_expos
assert data['status'] == 'updated'
assert data['instrument'] == 'DECam'
assert data['timeout'] == 120
assert data['updateargs'] == updateargs
assert data['updateargs'] == decam_raw_origin_exposures_parameters
assert data['hold'] == 0
assert data['pause'] == 1

Expand Down
27 changes: 16 additions & 11 deletions tests/fixtures/decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ def decam_raw_origin_exposures( decam_raw_origin_exposures_parameters ):


@pytest.fixture(scope="session")
def decam_filename(download_url, data_dir, decam_cache_dir):
def decam_exposure_name():
return 'c4d_230702_080904_ori.fits.fz'

@pytest.fixture(scope="session")
def decam_filename(download_url, data_dir, decam_exposure_name, decam_cache_dir):
"""Secure a DECam exposure.
Pulled from the SeeChange test data cache maintained on the web at
Expand All @@ -196,7 +200,7 @@ def decam_filename(download_url, data_dir, decam_cache_dir):
"""
# base_name = 'c4d_221104_074232_ori.fits.fz'
base_name = 'c4d_230702_080904_ori.fits.fz'
base_name = decam_exposure_name
filename = os.path.join(data_dir, base_name)
os.makedirs(os.path.dirname(filename), exist_ok=True)
url = os.path.join(download_url, 'DECAM', base_name)
Expand Down Expand Up @@ -263,8 +267,6 @@ def decam_small_image(decam_raw_image):
yield image


# TODO : produce pre-created source lists, wcs, and zp for the references,
# to speed up creation of this datastore
@pytest.fixture
def decam_datastore(
datastore_factory,
Expand All @@ -287,9 +289,9 @@ def decam_datastore(
"""
ds = datastore_factory(
decam_exposure,
'N1',
'S3',
cache_dir=decam_cache_dir,
cache_base_name='115/c4d_20221104_074232_N1_g_Sci_NBXRIO',
cache_base_name='007/c4d_20230702_080904_S3_r_Sci_NBXRIO',
save_original_image=True
)
# This save is redundant, as the datastore_factory calls save_and_commit
Expand Down Expand Up @@ -377,7 +379,7 @@ def decam_fits_image_filename2(download_url, decam_cache_dir):
# recalcualte it?)
@pytest.fixture( scope="session" )
def decam_elais_e1_two_refs_datastore( code_version, download_url, decam_cache_dir, data_dir, datastore_factory ):
filebase = 'ELAIS-E1-g-templ'
filebase = 'ELAIS-E1-r-templ'

dses = []
delete_list = []
Expand Down Expand Up @@ -438,7 +440,10 @@ def decam_elais_e1_two_refs_datastore( code_version, download_url, decam_cache_d
if not os.getenv( "LIMIT_CACHE_USAGE" ):
copy_to_cache( image, decam_cache_dir )

ds = datastore_factory(image, cache_dir=decam_cache_dir, cache_base_name=f'007/{filebase}.{chip:02d}')
ds = datastore_factory(image,
cache_dir=decam_cache_dir,
cache_base_name=f'007/{filebase}.{chip:02d}',
no_sub=True)

for filename in image.get_fullpath( as_list=True ):
assert os.path.isfile( filename )
Expand All @@ -462,7 +467,7 @@ def decam_elais_e1_two_refs_datastore( code_version, download_url, decam_cache_d

ImageAligner.cleanup_temp_images()

@pytest.fixture( scope="session" )
@pytest.fixture
def decam_elais_e1_two_references( decam_elais_e1_two_refs_datastore ):
refs = []
with SmartSession() as session:
Expand Down Expand Up @@ -506,11 +511,11 @@ def decam_elais_e1_two_references( decam_elais_e1_two_refs_datastore ):
session.delete(ref.provenance) # should also delete the reference image
session.commit()

@pytest.fixture( scope="session" )
@pytest.fixture
def decam_reference( decam_elais_e1_two_references ):
return decam_elais_e1_two_references[0]

@pytest.fixture( scope="session" )
@pytest.fixture
def decam_ref_datastore( decam_elais_e1_two_refs_datastore ):
return decam_elais_e1_two_refs_datastore[0]

Expand Down
Loading

0 comments on commit 9e3687f

Please sign in to comment.