Exemple #1
0
    def add_to_patch(self, filepath, index=None, verbose=False, **kwargs):
        """
        Add a file to the patch after initialization

        Args:
            filepath <str> - path to file which is to be added to the patch

        Kwargs:
            index <int> -  list index at which the file is inserted; default -1
            data <list/np.ndarray> - add the data of the .fits file directly
            hdr <dict> - add the header of the .fits file directly
            px2arcsec <float,float> - overwrite the pixel scale in the .fits header (in arcsecs)
            refpx <int,int> - overwrite reference pixel coordinates in .fits header (in pixels)
            refval <float,float> - overwrite reference pixel values in .fits header (in degrees)
            photzp <float> - overwrite photometric zero-point information
            verbose <bool> - verbose mode; print command line statements

        Return:
            filepath <str> - validated filepath which was added to the patch
        """
        filepath = SkyF.check_path(filepath, check_ext=False)
        if index is None or index == -1:
            self.filepaths.append(filepath)
            self.fs.append(SkyF(filepath, **kwargs))
        else:
            self.filepaths.insert(index, filepath)
            self.fs.insert(index, SkyF(filepath, **kwargs))
        if verbose:
            print(self.__v__)
        return filepath
Exemple #2
0
 def setUp(self):
     # arguments and keywords
     self.test_fits = os.path.abspath(os.path.dirname(__file__)) \
                      + '/W3+3-2.U.12907_13034_7446_7573.fits'
     # __init__ test
     self.skyf = SkyF(self.test_fits)
     # verbosity
     self.v = {'verbose': 1}
     print("")
     print(self.separator)
     print(self.shortDescription())
Exemple #3
0
 def setUp(self):
     # arguments and keywords
     self.test_fits = os.path.abspath(os.path.dirname(__file__)) \
                      + '/W3+3-2.I.12907_13034_7446_7573.fits'
     self.test_ftss = os.path.dirname(self.test_fits)
     # __init__ test
     self.skyf = SkyF(self.test_fits)
     self.skyp = SkyPatch(self.test_ftss)
     self.roi = ROISelector(self.skyf.data)
     # verbosity
     self.v = {'verbose': 1}
     print("")
     print(self.separator)
     print(self.shortDescription())
Exemple #4
0
    def __init__(self, files, verbose=False, **kwargs):
        """
        Initialize parsing of a fits file with a directory name

        Args:
            files <str/list(str)> - list of .fits files or directory string containing the files

        Kwargs:
            data <list(list/np.ndarray)> - add the data of the .fits file directly
            hdr <list(dict)> - add the header of the .fits file directly
            px2arcsec <list(float,float)> - overwrite the pixel scale in the .fits header (in arcs)
            refpx <list(int,int)> - overwrite reference pixel coordinates in .fits header (in px)
            refval <list(float,float)> - overwrite reference pixel values in .fits header (in deg)
            photzp <list(float)> - overwrite photometric zero-point information
            verbose <bool> - verbose mode; print command line statements

        Return:
            <SkyPatch object> - standard initializer
        """
        # collect all files
        if isinstance(files, (tuple, list)):  # input as list of files
            self.filepaths = self.find_files(files)
        elif isinstance(files, str) and any(
            [files.endswith(ext)
             for ext in ('.fits', '.fit', '.fts')]):  # single file input
            self.filepaths = self.find_files([files])
        elif isinstance(files, str):  # input as directory string
            self.filepaths = self.find_files(files)
        else:  # if there even is such a case
            self.filepaths = self.find_files(files)
        # keyword defaults
        for k in SkyF.params:
            kwargs.setdefault(k, [None] * self.N)
        # handle collective keyword inputs
        for k in SkyF.params:
            if not isinstance(kwargs[k], list) or len(kwargs[k]) != self.N:
                kwargs[k] = [kwargs[k]] * self.N
        # skyf instances for all files
        self.fs = [None] * self.N
        for i, f in enumerate(self.filepaths):
            self.fs[i] = SkyF(f, **{k: kwargs[k][i] for k in SkyF.params})
        if verbose:
            print(self.__v__)
Exemple #5
0
 def test_SkyF(self):
     """ # SkyF """
     print(">>> {}".format(self.test_fits))
     skyf = SkyF(self.test_fits, **self.v)
     self.assertIsInstance(skyf, SkyF)
     self.assertEqual(skyf, self.skyf)