shapepipe.utilities.cfis
shapepipe.utilities.cfis¶
CFIS TOOLS.
CFIS module.
- Authors
Martin Kilbinger
- exception CfisError[source]¶
Bases:
Exception
Cfis Error.
Generic error that is raised by this script.
- class image(name, ra, dec, exp_time=- 1, valid='Unknown')[source]¶
Bases:
object
Image Class.
Class to store and create image information.
- Parameters
- cut(no_cuts=False)[source]¶
Cut.
Return True (False) if image does (not) need to be cut from selection.
- get_ID()[source]¶
Get ID.
Return image ID.
- Returns
image iD
- Return type
- Raises
ValueError – if name does not match to ID pattern
- print(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, base_name=False, name_only=True, ID_only=False)[source]¶
Print.
Print image information as ascii Table column.
- Parameters
file (file, optional, default=sys.stdout) – output file handle
base_name (bool, optional, default=False) – if True (False), print image base name (full path)
name_only (bool, optional, default=False) – if True, do not print metainfo
ID_only (bool, optional, default=False) – if True, only print file ID instead of entire name
- Raises
ValueError – if name does not match to ID pattern
- log_command(argv, name=None, close_no_return=True)[source]¶
Log Command.
Write command with arguments to a file or stdout. Choose name = ‘sys.stdout’ or ‘sys.stderr’ for output on sceen.
- Parameters
- Returns
log file handler (if close_no_return is False)
- Return type
filehandler
- my_string_split(string, num=- 1, verbose=False, stop=False, sep=None)[source]¶
My String Split.
Split a string into a list of strings. Choose as separator the first in the list [space, underscore] that occurs in the string. (Thus, if both occur, use space.)
- Parameters
- Raises
CfisError – If number of elements in string and num are different, for stop=True
ValueError – If no separator found in string
- Returns
List of string on success, and None if failed
- Return type
- get_file_pattern(pattern, band, image_type, want_re=True, ext=True)[source]¶
Get File Pattern.
Return file pattern of CFIS image file.
- Parameters
pattern (str) – input pattern, can be ‘’
band (str) – band, one of ‘r’, ‘u’
image_type (str) – image type, one of ‘exposure’, ‘exposure_flag’, ‘exposure_flag.fz’, ‘exposure_weight’, ‘exposure_weight.fz’, ‘tile’, ‘cat’, ‘weight’, ‘weight.fz’
want_re (bool, optional, default=True) – return regular expression if True
ext (bool, optional, default=True) – if True add file extention to pattern
- Returns
output pattern
- Return type
- get_tile_number_from_coord(ra, dec, return_type=<class 'str'>)[source]¶
Get Tile Number From Coord.
Return CFIS stacked image tile number covering input coordinates. This is the inverse to get_tile_coord_from_nixy.
- get_tile_coord_from_nixy(nix, niy)[source]¶
Get Tile Coord From Nixy.
Return coordinates corresponding to tile with number (nix,niy). This is the inverse to get_tile_number_from_coord.
- get_tile_name(nix, niy, band, image_type='tile', input_format='full')[source]¶
Get Tile Name.
Return tile name for given tile numbers.
- Parameters
- Raises
CfisError – for invalid type
- Returns
tile name
- Return type
- get_tile_number_list(tile_name_list)[source]¶
Get Tile Number List.
Return tile numbers of given image tiles.
- Parameters
tile_name_list (list of str) – tile names
- Returns
tile numbers for x and tile numbers for y
- Return type
- get_Angle(str_coord)[source]¶
Get Angle.
Return Angles ra, dec from coordinate string
- Parameters
str_coord (string) – string of input coordinates
- Returns
right ascension and declination
- Return type
- get_Angle_arr(str_coord, num=- 1, wrap=True, verbose=False)[source]¶
Get Angle Arr.
Return array of Angles from coordinate string
- Parameters
- Returns
array of sky coordinates (pairs ra, dec)
- Return type
numpy.ndarray of SkyCoord
- create_image_list(fname, ra, dec, exp_time=[], valid=[])[source]¶
Create Image List.
Return list of image information.
- Parameters
fname (list of str) – file names
ra (list of str) – right ascension
dec (list of str) – declination
exp_time (list of int, optional, default=[]) – exposure time
valid (list of str, optional, default=[]) – QSO exposure validation flag
- Returns
list of image information
- Return type
list of images
- get_image_list(inp, band, image_type, col=None, input_format='full', verbose=False)[source]¶
Get Image List.
Return list of images.
- Parameters
inp (str) – file name or direcory path
band (str) – optical band
image_type (str) – image type (‘tile’, ‘exposure’, ‘cat’, ‘weight’, ‘weight.fz’)
col (str, optionalm default=None) – column name for file list input file
input_format (str, optional, default='full') – ‘full’ (name) or ‘ID_only’ input format for image names
verbose (bool, optional, default=False) – verbose output if True
- Returns
image list
- Return type
list of class images
- find_image_at_coord(images, coord, band, image_type, no_cuts=False, input_format='full', verbose=False)[source]¶
Find Image At Coordinates.
Return image covering given coordinate.
- Parameters
images (list of class image) – list of images
coord (str) – coordinate ra and dec with units
band (str) – optical band
image_type (str) – image type (‘tile’, ‘weight’, ‘weight.fz’, ‘exposure’, ‘exposure_weight’, ‘exposure_weight.fz’, ‘exposure_flag’, ‘exposure_flag.fz’, ‘cat’)
no_cuts (bool, optional, default=False) – no cuts (of short exposure, validation flag) if True
input_format (str, optional, default='full') – one of ‘full’, ‘ID_only’
verbose (bool, optional) – verbose output if True, default=False
- Raises
CfisError – if image type is not ‘tile’; if more than one tile matches if input image coordinates are already set
- Returns
Found image(s), None if none found.
- Return type
list of images
- find_images_in_area(images, angles, band, image_type, no_cuts=False, verbose=False)[source]¶
Fine Images In Area.
Return image list within coordinate area (rectangle)
- Parameters
images (list of class image) – list of images
angles (array(2) of SkyCoord) – coordinates [(ra0, dec0), (ra1, dec1)]
band (string) – optical band
image_type (str) – image type (‘tile’, ‘exposure’, ‘cat’, ‘weight’, ‘weight.fz’)
no_cuts (bool, optional, default=False) – no cuts (of short exposure, validation flag) if True
verbose (bool, optional, default=False) – verbose output if True
- Returns
found images
- Return type
list of images
- plot_area(images, angles, image_type, outbase, interactive, col=None, show_numbers=False, show_circle=True, show_area_border=False, ax=None, lw=None, save=True, dxy=0)[source]¶
Plot Area.
Plot images within area.
- Parameters
images (numpy.ndarray of image) – images
angles (numpy.ndarray (SkyCoord, 2)) – Corner coordinates of area rectangle
image_type (str) – image type (‘tile’, ‘exposure’, ‘cat’, weight’)
outbase (str) – output file name base
interactive (bool) – show plot if True
col (str, optional, default=None) – color
show_numbers (bool, optional, default=False) – show tile numbers if True
show_circle (bool, optional, default=True) – plot circle center and circumference around area if True
show_area_border (bool, optional, default=False) – plot rectangle around area
ax (axes, optional, default None) – Init axes if None
lw (float, optional, default None) – line width
save (bool, optional, default=True) – save plot to pdf file if True
dxy (float, optional, default=0) – shift
- square_from_centre(x, y, dx, dy, dxy=0)[source]¶
Square From Centre.
Return coordinate vectors of corners that define a closed square for plotting.
- square_from_corners(ang0, ang1)[source]¶
Square From Corners.
Return coordinate vectors of corners that define a closed square for plotting.
- Parameters
ang0 (Angle) – lower-left square coordinates
ang1 (Angle) – upper-right square coordinates
- Returns
square coordinates in x and y, in unit ‘unitdef’
- Return type