Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1797b8e
init + utilities
martinkilbinger Jun 14, 2021
2b1adfd
Merge remote-tracking branch 'origin/mk' into mk
martinkilbinger Jun 16, 2021
6b3bf9b
removed debug print comment
martinkilbinger Jun 18, 2021
4a50552
Merge branch 'mk' of github.com:martinkilbinger/shapepipe into mk
martinkilbinger Jun 18, 2021
11a26ad
notebooks
martinkilbinger Jun 30, 2021
ddaf48b
config_exp_mccd: Use MCCD inv_opt config file, works for 'outliers' v…
martinkilbinger Jul 12, 2021
1cf19cf
CFIS footprint: Added constellations; job_sp: added -c flag for confi…
martinkilbinger Jul 12, 2021
5088376
Added MCCD config files
martinkilbinger Jul 12, 2021
446386f
202007 W3 complete
martinkilbinger Jul 12, 2021
11eefe0
FITSCatalogue: overwrite option working for any FITS file, not only i…
martinkilbinger Jul 13, 2021
deb73a1
Merge remote-tracking branch 'upstream/master' into overwrite
martinkilbinger Jul 13, 2021
fef7d56
canfar.py to new style
martinkilbinger Jul 19, 2021
7cd09eb
Merge remote-tracking branch 'upstream/develop' into overwrite
martinkilbinger Jul 19, 2021
1794376
removed MKDEBUG comment
martinkilbinger Jul 23, 2021
4cc366a
file_io overwrite bug fixed
martinkilbinger Jul 24, 2021
4facf22
Merge remote-tracking branch 'upstream/develop' into overwrite
martinkilbinger Jul 30, 2021
c6dc7f7
Merge remote-tracking branch 'upstream/develop' into overwrite
martinkilbinger Jul 30, 2021
76d71d2
small changes due to review
martinkilbinger Jul 30, 2021
25f1e23
review changes
martinkilbinger Jul 30, 2021
895f9b7
cfis first half to new syntax
martinkilbinger Jul 30, 2021
4f8fc6e
cfis 2nd half to new syntax
martinkilbinger Jul 30, 2021
6dbcc9f
passing tests
martinkilbinger Jul 30, 2021
8fbe6fb
Merge remote-tracking branch 'upstream/develop' into overwrite
martinkilbinger Jul 30, 2021
0a49079
python errors fixed
martinkilbinger Jul 30, 2021
dd8574c
Merge remote-tracking branch 'upstream/develop' into overwrite
martinkilbinger Aug 4, 2021
e355eae
minor changes
martinkilbinger Aug 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/python/merge_star_cat_mccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ def create_full_cat(input_dir, input_file_pattern, output_path, verbose=False):
ccd_nb = list(starcat_j[1].data['CCD_ID_LIST'])

# Prepare output FITS catalogue
output = sc.FITSCatalog(output_path,
open_mode=sc.BaseCatalog.OpenMode.ReadWrite)
output = sc.FITSCatalog(
output_path,
open_mode=sc.BaseCatalog.OpenMode.ReadWrite
)

# Collect columns
# convert back to sigma for consistency
Expand All @@ -234,7 +236,7 @@ def create_full_cat(input_dir, input_file_pattern, output_path, verbose=False):
# Write file
if verbose:
print('Writing full PSF catalog file {}...'.format(output_path))
output.save_as_fits(data)
output.save_as_fits(data, overwrite=True)


def log_command(argv, name=None, close_no_return=True):
Expand Down
8 changes: 5 additions & 3 deletions scripts/python/merge_star_cat_psfex.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ def create_full_cat(input_dir, input_file_pattern, output_path, verbose=False):
ccd_nb += [re.split(r"\-([0-9]*)\-([0-9]+)\.", name)[-2]]*len(starcat_j[2].data['RA'])

# Prepare output FITS catalogue
output = sc.FITSCatalog(output_path,
open_mode=sc.BaseCatalog.OpenMode.ReadWrite)
output = sc.FITSCatalog(
output_path,
open_mode=sc.BaseCatalog.OpenMode.ReadWrite
)

# Collect columns
# convert back to sigma for consistency
Expand All @@ -216,7 +218,7 @@ def create_full_cat(input_dir, input_file_pattern, output_path, verbose=False):
# Write file
if verbose:
print('Writing full PSF catalog file {}...'.format(output_path))
output.save_as_fits(data)
output.save_as_fits(data, overwrite=True)


def main(argv=None):
Expand Down
2 changes: 1 addition & 1 deletion scripts/python/stats_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from optparse import OptionParser

import cfis
import shapepipe.utilities.cfis as cfis


def params_default():
Expand Down
1 change: 0 additions & 1 deletion shapepipe/modules/find_exposures_package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
"""

__all__ = ['find_exposures.py']

1 change: 0 additions & 1 deletion shapepipe/modules/split_exp_package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
"""

__all__ = ['split_exp_script.py']

2 changes: 1 addition & 1 deletion shapepipe/modules/spread_model_package/spread_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def process(self):
skip_obj = False
spread_model_final = []
spread_model_err_final = []
for idx id_tmp in enumerate(obj_id):
for idx, id_tmp in enumerate(obj_id):
sigma_list = []

if psf_cat[str(id_tmp)] == 'empty':
Expand Down
26 changes: 13 additions & 13 deletions shapepipe/pipeline/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def open(self):

# ------------------------------------------------------------------------------------------------
# MODIFIED
def create(self, ext_name=None, overwrite=True, s_hdu=True, sex_cat_path=None):
def create(self, ext_name=None, s_hdu=True, sex_cat_path=None):
"""!
Create an empty catalog with a FITS format
@param ext_name extension name or number
Expand All @@ -468,7 +468,7 @@ def create(self, ext_name=None, overwrite=True, s_hdu=True, sex_cat_path=None):
sex_cat.open()
secondary_hdu = sex_cat._cat_data[1]
self._cat_data = fits.HDUList([primary_hdu, secondary_hdu])
self._cat_data.writeto(self.fullpath, overwrite=overwrite)
self._cat_data.writeto(self.fullpath, overwrite=True)
sex_cat.close()
del(sex_cat)
else:
Expand All @@ -478,10 +478,10 @@ def create(self, ext_name=None, overwrite=True, s_hdu=True, sex_cat_path=None):
elif s_hdu:
secondary_hdu = fits.BinTableHDU(data=None, header=None, name=ext_name)
self._cat_data = fits.HDUList([primary_hdu, secondary_hdu])
self._cat_data.writeto(self.fullpath, overwrite=overwrite)
self._cat_data.writeto(self.fullpath, overwrite=True)
else:
self._cat_data = fits.HDUList([primary_hdu])
self._cat_data.writeto(self.fullpath, overwrite=overwrite)
self._cat_data.writeto(self.fullpath, overwrite=True)

# ------------------------------------------------------------------------------------------------
# ADDED
Expand Down Expand Up @@ -581,12 +581,12 @@ def save_as_fits(self, data=None, names=None, ext_name=None, sex_cat_path=None,
data = np.array(data[names[0]])
else:
data = [np.array(data[i]) for i in names]
self._save_to_fits(data, names, it, ext_name, sex_cat_path)
self._save_to_fits(data, names, it, ext_name, sex_cat_path, overwrite=overwrite)

elif type(data) is np.recarray:
names = list(data.dtype.names)
it = names
self._save_to_fits(data, names, it, ext_name, sex_cat_path)
self._save_to_fits(data, names, it, ext_name, sex_cat_path, overwrite=overwrite)

elif type(data) is fits.fitsrec.FITS_rec:
self._save_from_recarray(data, ext_name, sex_cat_path)
Expand All @@ -600,20 +600,20 @@ def save_as_fits(self, data=None, names=None, ext_name=None, sex_cat_path=None,
raise ValueError('Names not provided')
else:
it = range(len(names))
self._save_to_fits(data, names, it, ext_name, sex_cat_path)
self._save_to_fits(data, names, it, ext_name, sex_cat_path, overwrite=overwrite)

elif type(data) is list:
if names is None:
raise ValueError('Names not provided')
it = range(len(names))
data = np.asarray(data)
self._save_to_fits(data, names, it, ext_name, sex_cat_path)
self._save_to_fits(data, names, it, ext_name, sex_cat_path, overwrite=overwrite)

elif type(data) is Table:
if names is None:
raise ValueError('Names not provided')
it = names
self._save_to_fits(data, names, it, ext_name, sex_cat_path)
self._save_to_fits(data, names, it, ext_name, sex_cat_path, overwrite=overwrite)

else:
if type(data) is np.ndarray:
Expand Down Expand Up @@ -1169,7 +1169,7 @@ def _get_python_col_type(self, col_type):

# ------------------------------------------------------------------------------------------------
# ADDED
def _save_to_fits(self, data, names, it, ext_name=None, sex_cat_path=None):
def _save_to_fits(self, data, names, it, ext_name=None, sex_cat_path=None, overwrite=False):
"""!
Save array of data as fits with their associated column names.
@param data array withe the data
Expand All @@ -1182,7 +1182,7 @@ def _save_to_fits(self, data, names, it, ext_name=None, sex_cat_path=None):
if data is None:
raise ValueError('Data not provided')

if self._file_exists(self.fullpath):
if self._file_exists(self.fullpath) and not overwrite:
if self._cat_data is None:
self.open()
if ext_name is None:
Expand Down Expand Up @@ -1229,7 +1229,7 @@ def _save_to_fits(self, data, names, it, ext_name=None, sex_cat_path=None):

# ------------------------------------------------------------------------------------------------
# ADDED
def _save_from_recarray(self, data=None, ext_name=None, sex_cat_path=None):
def _save_from_recarray(self, data=None, ext_name=None, sex_cat_path=None, overwrite=False):
"""!
Save a numpy.recarray or astropy.io.fits.fitsrec.FITS_rec into a fits.
@param data data to store
Expand All @@ -1241,7 +1241,7 @@ def _save_from_recarray(self, data=None, ext_name=None, sex_cat_path=None):
if data is None:
raise ValueError('Data not provided')

if self._file_exists(self.fullpath):
if self._file_exists(self.fullpath) and not overwrite:
if self._cat_data is None:
self.open()
if ext_name is None:
Expand Down
24 changes: 14 additions & 10 deletions shapepipe/utilities/canfar.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ def command(self):
def command(self, value):

if value not in self._avail_commands:
raise ValueError('vos command must be one of {}'
''.format(self._avail_commands))
raise ValueError(
f'vos command must be one of {self._avail_commands}'
)

self._command = getattr(vosc, value)

Expand All @@ -88,18 +89,20 @@ def __call__(self, *args, **kwargs):
try:
self._command()

except Exception:
raise vosError(f'Error in VOs command: {self._command.__name__}')
except:
raise vosError(
f'Error in VOs command: {self._command.__name__}'
)


def download(source, target, verbose=False):
"""Download file from vos.

Parameters
----------
source : string
source : str
source path on vos
target : string
target : str
target path
verbose : bool, optional, default=False
verbose output if True
Expand All @@ -108,21 +111,22 @@ def download(source, target, verbose=False):
-------
status : bool
status, True/False or success/failure
"""

cmd = 'vcp'

if not os.path.exists(target):
sys.argv = [cmd, source, target]
if verbose:
print('Downloading file {} to {}...'.format(source, target))
print(f'Downloading file {source} to {target}...')
vcp = vosHandler(cmd)

vcp()
if verbose:
print('Download finished.')
else:
if verbose:
print('Target file {} exists, skipping download.'.format(target))
print(f'Target file {target} exists, skipping download.')


def dir_list(path, verbose=False):
Expand All @@ -132,7 +136,7 @@ def dir_list(path, verbose=False):

Parameters
----------
path : string
path : str
path on vos, starts with 'vos:cfis/...'
verbose : bool, optional, default=False
verbose output if True
Expand All @@ -143,7 +147,7 @@ def dir_list(path, verbose=False):

Returns
-------
vls_out : array of string
vls_out : array of str
file or directory at path
"""

Expand Down
Loading