Esempio n. 1
0
 def test_load(self):
     """ Test to load a fits file.
         Also tests if DataParent.load correctly finds
         data object for file
     """
     from darepype.drp import DataParent
     from darepype.drp import DataFits
     dp = DataParent(config=os.path.join(TESTDATA_FOLDER, 'testconf.txt'))
     df = dp.load(os.path.join(TESTDATA_FOLDER, 'testfit.fits'))
     self.assertIsInstance(df, DataFits)
     self.assertGreater(sum(df.image.shape), 0)
Esempio n. 2
0
 def test_load(self):
     """ Test to laod a text file.
         Also tests if DataParent.load correctly finds
         data object for file
     """
     from darepype.drp import DataParent
     from darepype.drp import DataText
     dp = DataParent(config=os.path.join(TESTDATA_FOLDER, 'testconf.txt'))
     dt = dp.load(os.path.join(TESTDATA_FOLDER, 'testtext.txt'))
     self.assertIsInstance(dt, DataText)
     self.assertGreater(len(dt.data), 0)
Esempio n. 3
0
 def test_mimo(self):
     """ Test a mimo step. Runs the step and makes sure
         that the output data is as expected.
     """
     dp = DataParent(config=CONFFILE)
     df1 = dp.load(FITSFILE)
     df2 = dp.load(FITSFILE)
     step = dp.getobject('StepMOParent')
     head = df1.header.copy()
     img = df1.image.copy()
     do1, _do2 = step([df1, df2])
     self.assertEqual(np.sum(img - do1.image), 0)
     self.assertNotEqual(head, do1.header)
Esempio n. 4
0
 def test_siso(self):
     """ Test siso step. Runs the step and makes sure
         that the data is the same but that the header
         has changed.
     """
     dp = DataParent(config=CONFFILE)
     df = dp.load(FITSFILE)
     head = df.header.copy()
     img = df.image.copy()
     step = dp.getobject('StepParent')
     do = step(df)
     self.assertEqual(np.sum(img - do.image), 0)
     self.assertNotEqual(head, do.header)
Esempio n. 5
0
 def test_imageHDUs(self):
     """ Test image, imageindex, imageget, imageset, imagedel
     """
     # Load test file
     from darepype.drp import DataParent
     dp = DataParent(config=os.path.join(TESTDATA_FOLDER, 'testconf.txt'))
     df = dp.load(os.path.join(TESTDATA_FOLDER, 'testfit.fits'))
     # Name the hdu
     df.imgnames[0] = "FIRST IMAGE"
     # Make copy first image to second hdu
     df.imageset(df.image, "Second Image", df.header)
     # Check imageindex for second image
     self.assertEqual(1, df.imageindex("Second Image"),
                      'check imageindex on 2 images')
     # Check imageget
     self.assertEqual(df.image.sum(), df.imageget("Second Image").sum())
     # Check imaagedel
     df.imagedel('First Image')
     self.assertEqual(3,
                      len(df.imgdata) + len(df.imgnames) + len(df.imgheads))
     self.assertEqual(0, df.imageindex("Second Image"), 'check imagedelete')
Esempio n. 6
0
 def test_getheader(self):
     """ Test header functions: Set and get header keywords
     """
     # Load test file
     from darepype.drp import DataParent
     dp = DataParent(config=os.path.join(TESTDATA_FOLDER, 'testconf.txt'))
     df = dp.load(os.path.join(TESTDATA_FOLDER, 'testfit.fits'))
     # Name the hdu
     df.imgnames[0] = "FIRST IMAGE"
     # Make copy first image to second hdu
     df.imageset(df.image, "Second Image", df.header)
     # Get getting values
     self.assertEqual(2, df.getheadval('NAXIS'), 'getheadval from header')
     self.assertEqual(3, df.getheadval('TESTVAL'),
                      'getheadval from config[header]')
     # Set value in each header
     df.setheadval('AVALUE', 10)
     df.setheadval('BVALUE', 20, None, 'Second Image')
     # Check values
     self.assertEqual(10, df.getheadval('AVALUE'),
                      'check setheadval primary header')
     self.assertEqual(20, df.getheadval('BVALUE', 'allheaders'),
                      'check setheadval second header')
Esempio n. 7
0
# Location of config files
baseconfig = os.path.join(codefolder, 'pipeline', 'Developments',
                          'stepwebastrometry', 'pipeconf_stonedge_auto.txt')
logging.basicConfig(
    filename=logfilename,
    level=logging.DEBUG,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")

os.chdir(codefolder)
if not os.path.exists(datafolder):
    os.mkdir(datafolder)
infilenames = [os.path.join(datafolder, f) for f in filenames]

### Load a file into a DataFits object
dparent = DataParent(config=baseconfig)
dfits = dparent.load(infilenames[0])
print(dfits.filename)

### Look at the FITS header of the loaded object
# print(repr(dfits.header))

### OPTIONAL BUT RECOMMENDED: Check if all necessary files exist
error_flag = False
# Check if configuration file exists
if not os.path.exists(baseconfig):
    print(
        'ERROR: The config file you specified, %s,\n  does NOT exist on your computer, fix "config" above'
        % baseconfig)
    error_flag = True
# Check if input files exist
for name in infilenames: