repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
SoftwareDefinedBuildings/XBOS
python/xbos/services/pundat.py
DataClient.tags
def tags(self, where, archiver="", timeout=DEFAULT_TIMEOUT): """ Retrieves tags for all streams matching the given WHERE clause Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [archiver]: if specified, this is the archiver to use. Else, ...
python
def tags(self, where, archiver="", timeout=DEFAULT_TIMEOUT): """ Retrieves tags for all streams matching the given WHERE clause Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [archiver]: if specified, this is the archiver to use. Else, ...
[ "def", "tags", "(", "self", ",", "where", ",", "archiver", "=", "\"\"", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "return", "self", ".", "query", "(", "\"select * where {0}\"", ".", "format", "(", "where", ")", ",", "archiver", ",", "timeout", ")...
Retrieves tags for all streams matching the given WHERE clause Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [archiver]: if specified, this is the archiver to use. Else, it will run on the first archiver passed into the constructor...
[ "Retrieves", "tags", "for", "all", "streams", "matching", "the", "given", "WHERE", "clause" ]
train
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/python/xbos/services/pundat.py#L129-L139
SoftwareDefinedBuildings/XBOS
python/xbos/services/pundat.py
DataClient.tags_uuids
def tags_uuids(self, uuids, archiver="", timeout=DEFAULT_TIMEOUT): """ Retrieves tags for all streams with the provided UUIDs Arguments: [uuids]: list of UUIDs [archiver]: if specified, this is the archiver to use. Else, it will run on the first archiver passed ...
python
def tags_uuids(self, uuids, archiver="", timeout=DEFAULT_TIMEOUT): """ Retrieves tags for all streams with the provided UUIDs Arguments: [uuids]: list of UUIDs [archiver]: if specified, this is the archiver to use. Else, it will run on the first archiver passed ...
[ "def", "tags_uuids", "(", "self", ",", "uuids", ",", "archiver", "=", "\"\"", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "if", "not", "isinstance", "(", "uuids", ",", "list", ")", ":", "uuids", "=", "[", "uuids", "]", "where", "=", "\" or \"", ...
Retrieves tags for all streams with the provided UUIDs Arguments: [uuids]: list of UUIDs [archiver]: if specified, this is the archiver to use. Else, it will run on the first archiver passed into the constructor for the client [timeout]: time in seconds to wait for a...
[ "Retrieves", "tags", "for", "all", "streams", "with", "the", "provided", "UUIDs" ]
train
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/python/xbos/services/pundat.py#L141-L154
SoftwareDefinedBuildings/XBOS
python/xbos/services/pundat.py
DataClient.data
def data(self, where, start, end, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given WHERE clause, retrieves all RAW data between the 2 given timestamps Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [start, end]: time references...
python
def data(self, where, start, end, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given WHERE clause, retrieves all RAW data between the 2 given timestamps Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [start, end]: time references...
[ "def", "data", "(", "self", ",", "where", ",", "start", ",", "end", ",", "archiver", "=", "\"\"", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "return", "self", ".", "query", "(", "\"select data in ({0}, {1}) where {2}\"", ".", "format", "(", "start", ...
With the given WHERE clause, retrieves all RAW data between the 2 given timestamps Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [start, end]: time references: [archiver]: if specified, this is the archiver to use. Else, it will run on the fir...
[ "With", "the", "given", "WHERE", "clause", "retrieves", "all", "RAW", "data", "between", "the", "2", "given", "timestamps" ]
train
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/python/xbos/services/pundat.py#L156-L167
SoftwareDefinedBuildings/XBOS
python/xbos/services/pundat.py
DataClient.data_uuids
def data_uuids(self, uuids, start, end, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given list of UUIDs, retrieves all RAW data between the 2 given timestamps Arguments: [uuids]: list of UUIDs [start, end]: time references: [archiver]: if specified, this is the a...
python
def data_uuids(self, uuids, start, end, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given list of UUIDs, retrieves all RAW data between the 2 given timestamps Arguments: [uuids]: list of UUIDs [start, end]: time references: [archiver]: if specified, this is the a...
[ "def", "data_uuids", "(", "self", ",", "uuids", ",", "start", ",", "end", ",", "archiver", "=", "\"\"", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "if", "not", "isinstance", "(", "uuids", ",", "list", ")", ":", "uuids", "=", "[", "uuids", "]",...
With the given list of UUIDs, retrieves all RAW data between the 2 given timestamps Arguments: [uuids]: list of UUIDs [start, end]: time references: [archiver]: if specified, this is the archiver to use. Else, it will run on the first archiver passed into the constru...
[ "With", "the", "given", "list", "of", "UUIDs", "retrieves", "all", "RAW", "data", "between", "the", "2", "given", "timestamps" ]
train
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/python/xbos/services/pundat.py#L169-L183
SoftwareDefinedBuildings/XBOS
python/xbos/services/pundat.py
DataClient.stats
def stats(self, where, start, end, pw, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given WHERE clause, retrieves all statistical data between the 2 given timestamps, using the given pointwidth Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main...
python
def stats(self, where, start, end, pw, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given WHERE clause, retrieves all statistical data between the 2 given timestamps, using the given pointwidth Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main...
[ "def", "stats", "(", "self", ",", "where", ",", "start", ",", "end", ",", "pw", ",", "archiver", "=", "\"\"", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "return", "self", ".", "query", "(", "\"select statistical({3}) data in ({0}, {1}) where {2}\"", "."...
With the given WHERE clause, retrieves all statistical data between the 2 given timestamps, using the given pointwidth Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [start, end]: time references: [pw]: pointwidth (window size of 2^pw nanosecon...
[ "With", "the", "given", "WHERE", "clause", "retrieves", "all", "statistical", "data", "between", "the", "2", "given", "timestamps", "using", "the", "given", "pointwidth" ]
train
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/python/xbos/services/pundat.py#L185-L197
SoftwareDefinedBuildings/XBOS
python/xbos/services/pundat.py
DataClient.window
def window(self, where, start, end, width, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given WHERE clause, retrieves all statistical data between the 2 given timestamps, using the given window size Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED...
python
def window(self, where, start, end, width, archiver="", timeout=DEFAULT_TIMEOUT): """ With the given WHERE clause, retrieves all statistical data between the 2 given timestamps, using the given window size Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED...
[ "def", "window", "(", "self", ",", "where", ",", "start", ",", "end", ",", "width", ",", "archiver", "=", "\"\"", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "return", "self", ".", "query", "(", "\"select window({3}) data in ({0}, {1}) where {2}\"", ".",...
With the given WHERE clause, retrieves all statistical data between the 2 given timestamps, using the given window size Arguments: [where]: the where clause (e.g. 'path like "keti"', 'SourceName = "TED Main"') [start, end]: time references: [width]: a time expression for the window size...
[ "With", "the", "given", "WHERE", "clause", "retrieves", "all", "statistical", "data", "between", "the", "2", "given", "timestamps", "using", "the", "given", "window", "size" ]
train
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/python/xbos/services/pundat.py#L216-L228
Danielhiversen/flux_led
flux_led/__main__.py
WifiLedBulb.brightness
def brightness(self): """Return current brightness 0-255. For warm white return current led level. For RGB calculate the HSV and return the 'value'. """ if self.mode == "ww": return int(self.raw_state[9]) else: _, _, v = colorsys.rgb_to_hsv(*self....
python
def brightness(self): """Return current brightness 0-255. For warm white return current led level. For RGB calculate the HSV and return the 'value'. """ if self.mode == "ww": return int(self.raw_state[9]) else: _, _, v = colorsys.rgb_to_hsv(*self....
[ "def", "brightness", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "\"ww\"", ":", "return", "int", "(", "self", ".", "raw_state", "[", "9", "]", ")", "else", ":", "_", ",", "_", ",", "v", "=", "colorsys", ".", "rgb_to_hsv", "(", "*", ...
Return current brightness 0-255. For warm white return current led level. For RGB calculate the HSV and return the 'value'.
[ "Return", "current", "brightness", "0", "-", "255", "." ]
train
https://github.com/Danielhiversen/flux_led/blob/13e87e06ff7589356c83e084a6be768ad1290557/flux_led/__main__.py#L544-L554
kyrus/python-junit-xml
junit_xml/__init__.py
decode
def decode(var, encoding): """ If not already unicode, decode it. """ if PY2: if isinstance(var, unicode): ret = var elif isinstance(var, str): if encoding: ret = var.decode(encoding) else: ret = unicode(var) els...
python
def decode(var, encoding): """ If not already unicode, decode it. """ if PY2: if isinstance(var, unicode): ret = var elif isinstance(var, str): if encoding: ret = var.decode(encoding) else: ret = unicode(var) els...
[ "def", "decode", "(", "var", ",", "encoding", ")", ":", "if", "PY2", ":", "if", "isinstance", "(", "var", ",", "unicode", ")", ":", "ret", "=", "var", "elif", "isinstance", "(", "var", ",", "str", ")", ":", "if", "encoding", ":", "ret", "=", "var...
If not already unicode, decode it.
[ "If", "not", "already", "unicode", "decode", "it", "." ]
train
https://github.com/kyrus/python-junit-xml/blob/9bb2675bf0058742da04285dcdcf8781eee03db0/junit_xml/__init__.py#L57-L73
esheldon/fitsio
fitsio/util.py
cfitsio_version
def cfitsio_version(asfloat=False): """ Return the cfitsio version as a string. """ # use string version to avoid roundoffs ver = '%0.3f' % _fitsio_wrap.cfitsio_version() if asfloat: return float(ver) else: return ver
python
def cfitsio_version(asfloat=False): """ Return the cfitsio version as a string. """ # use string version to avoid roundoffs ver = '%0.3f' % _fitsio_wrap.cfitsio_version() if asfloat: return float(ver) else: return ver
[ "def", "cfitsio_version", "(", "asfloat", "=", "False", ")", ":", "# use string version to avoid roundoffs", "ver", "=", "'%0.3f'", "%", "_fitsio_wrap", ".", "cfitsio_version", "(", ")", "if", "asfloat", ":", "return", "float", "(", "ver", ")", "else", ":", "r...
Return the cfitsio version as a string.
[ "Return", "the", "cfitsio", "version", "as", "a", "string", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/util.py#L19-L28
esheldon/fitsio
fitsio/util.py
is_little_endian
def is_little_endian(array): """ Return True if array is little endian, False otherwise. Parameters ---------- array: numpy array A numerical python array. Returns ------- Truth value: True for little-endian Notes ----- Strings are neither big or little end...
python
def is_little_endian(array): """ Return True if array is little endian, False otherwise. Parameters ---------- array: numpy array A numerical python array. Returns ------- Truth value: True for little-endian Notes ----- Strings are neither big or little end...
[ "def", "is_little_endian", "(", "array", ")", ":", "if", "numpy", ".", "little_endian", ":", "machine_little", "=", "True", "else", ":", "machine_little", "=", "False", "byteorder", "=", "array", ".", "dtype", ".", "base", ".", "byteorder", "return", "(", ...
Return True if array is little endian, False otherwise. Parameters ---------- array: numpy array A numerical python array. Returns ------- Truth value: True for little-endian Notes ----- Strings are neither big or little endian. The input must be a simple numpy ...
[ "Return", "True", "if", "array", "is", "little", "endian", "False", "otherwise", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/util.py#L73-L98
esheldon/fitsio
fitsio/util.py
array_to_native
def array_to_native(array, inplace=False): """ Convert an array to the native byte order. NOTE: the inplace keyword argument is not currently used. """ if numpy.little_endian: machine_little = True else: machine_little = False data_little = False if array.dtype.names is...
python
def array_to_native(array, inplace=False): """ Convert an array to the native byte order. NOTE: the inplace keyword argument is not currently used. """ if numpy.little_endian: machine_little = True else: machine_little = False data_little = False if array.dtype.names is...
[ "def", "array_to_native", "(", "array", ",", "inplace", "=", "False", ")", ":", "if", "numpy", ".", "little_endian", ":", "machine_little", "=", "True", "else", ":", "machine_little", "=", "False", "data_little", "=", "False", "if", "array", ".", "dtype", ...
Convert an array to the native byte order. NOTE: the inplace keyword argument is not currently used.
[ "Convert", "an", "array", "to", "the", "native", "byte", "order", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/util.py#L101-L134
esheldon/fitsio
fitsio/util.py
mks
def mks(val): """ make sure the value is a string, paying mind to python3 vs 2 """ if sys.version_info > (3, 0, 0): if isinstance(val, bytes): sval = str(val, 'utf-8') else: sval = str(val) else: sval = str(val) return sval
python
def mks(val): """ make sure the value is a string, paying mind to python3 vs 2 """ if sys.version_info > (3, 0, 0): if isinstance(val, bytes): sval = str(val, 'utf-8') else: sval = str(val) else: sval = str(val) return sval
[ "def", "mks", "(", "val", ")", ":", "if", "sys", ".", "version_info", ">", "(", "3", ",", "0", ",", "0", ")", ":", "if", "isinstance", "(", "val", ",", "bytes", ")", ":", "sval", "=", "str", "(", "val", ",", "'utf-8'", ")", "else", ":", "sval...
make sure the value is a string, paying mind to python3 vs 2
[ "make", "sure", "the", "value", "is", "a", "string", "paying", "mind", "to", "python3", "vs", "2" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/util.py#L143-L155
esheldon/fitsio
fitsio/hdu/table.py
_extract_vararray_max
def _extract_vararray_max(tform): """ Extract number from PX(number) """ first = tform.find('(') last = tform.rfind(')') if first == -1 or last == -1: # no max length specified return -1 maxnum = int(tform[first+1:last]) return maxnum
python
def _extract_vararray_max(tform): """ Extract number from PX(number) """ first = tform.find('(') last = tform.rfind(')') if first == -1 or last == -1: # no max length specified return -1 maxnum = int(tform[first+1:last]) return maxnum
[ "def", "_extract_vararray_max", "(", "tform", ")", ":", "first", "=", "tform", ".", "find", "(", "'('", ")", "last", "=", "tform", ".", "rfind", "(", "')'", ")", "if", "first", "==", "-", "1", "or", "last", "==", "-", "1", ":", "# no max length speci...
Extract number from PX(number)
[ "Extract", "number", "from", "PX", "(", "number", ")" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L2004-L2016
esheldon/fitsio
fitsio/hdu/table.py
_get_col_dimstr
def _get_col_dimstr(tdim, is_string=False): """ not for variable length """ dimstr = '' if tdim is None: dimstr = 'array[bad TDIM]' else: if is_string: if len(tdim) > 1: dimstr = [str(d) for d in tdim[1:]] else: if len(tdim) > 1 or ...
python
def _get_col_dimstr(tdim, is_string=False): """ not for variable length """ dimstr = '' if tdim is None: dimstr = 'array[bad TDIM]' else: if is_string: if len(tdim) > 1: dimstr = [str(d) for d in tdim[1:]] else: if len(tdim) > 1 or ...
[ "def", "_get_col_dimstr", "(", "tdim", ",", "is_string", "=", "False", ")", ":", "dimstr", "=", "''", "if", "tdim", "is", "None", ":", "dimstr", "=", "'array[bad TDIM]'", "else", ":", "if", "is_string", ":", "if", "len", "(", "tdim", ")", ">", "1", "...
not for variable length
[ "not", "for", "variable", "length" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L2019-L2037
esheldon/fitsio
fitsio/hdu/table.py
_npy2fits
def _npy2fits(d, table_type='binary', write_bitcols=False): """ d is the full element from the descr """ npy_dtype = d[1][1:] if npy_dtype[0] == 'S' or npy_dtype[0] == 'U': name, form, dim = _npy_string2fits(d, table_type=table_type) else: name, form, dim = _npy_num2fits( ...
python
def _npy2fits(d, table_type='binary', write_bitcols=False): """ d is the full element from the descr """ npy_dtype = d[1][1:] if npy_dtype[0] == 'S' or npy_dtype[0] == 'U': name, form, dim = _npy_string2fits(d, table_type=table_type) else: name, form, dim = _npy_num2fits( ...
[ "def", "_npy2fits", "(", "d", ",", "table_type", "=", "'binary'", ",", "write_bitcols", "=", "False", ")", ":", "npy_dtype", "=", "d", "[", "1", "]", "[", "1", ":", "]", "if", "npy_dtype", "[", "0", "]", "==", "'S'", "or", "npy_dtype", "[", "0", ...
d is the full element from the descr
[ "d", "is", "the", "full", "element", "from", "the", "descr" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L2106-L2117
esheldon/fitsio
fitsio/hdu/table.py
_npy_num2fits
def _npy_num2fits(d, table_type='binary', write_bitcols=False): """ d is the full element from the descr For vector,array columns the form is the total counts followed by the code. For array columns with dimension greater than 1, the dim is set to (dim1, dim2, ...) So it is treated lik...
python
def _npy_num2fits(d, table_type='binary', write_bitcols=False): """ d is the full element from the descr For vector,array columns the form is the total counts followed by the code. For array columns with dimension greater than 1, the dim is set to (dim1, dim2, ...) So it is treated lik...
[ "def", "_npy_num2fits", "(", "d", ",", "table_type", "=", "'binary'", ",", "write_bitcols", "=", "False", ")", ":", "dim", "=", "None", "name", "=", "d", "[", "0", "]", "npy_dtype", "=", "d", "[", "1", "]", "[", "1", ":", "]", "if", "npy_dtype", ...
d is the full element from the descr For vector,array columns the form is the total counts followed by the code. For array columns with dimension greater than 1, the dim is set to (dim1, dim2, ...) So it is treated like an extra dimension
[ "d", "is", "the", "full", "element", "from", "the", "descr" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L2120-L2175
esheldon/fitsio
fitsio/hdu/table.py
_npy_string2fits
def _npy_string2fits(d, table_type='binary'): """ d is the full element from the descr form for strings is the total number of bytes followed by A. Thus for vector or array columns it is the size of the string times the total number of elements in the array. Then the dim is set to (si...
python
def _npy_string2fits(d, table_type='binary'): """ d is the full element from the descr form for strings is the total number of bytes followed by A. Thus for vector or array columns it is the size of the string times the total number of elements in the array. Then the dim is set to (si...
[ "def", "_npy_string2fits", "(", "d", ",", "table_type", "=", "'binary'", ")", ":", "dim", "=", "None", "name", "=", "d", "[", "0", "]", "npy_dtype", "=", "d", "[", "1", "]", "[", "1", ":", "]", "if", "npy_dtype", "[", "0", "]", "!=", "'S'", "an...
d is the full element from the descr form for strings is the total number of bytes followed by A. Thus for vector or array columns it is the size of the string times the total number of elements in the array. Then the dim is set to (sizeofeachstring, dim1, dim2, ...) So it is treated like...
[ "d", "is", "the", "full", "element", "from", "the", "descr" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L2178-L2241
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.get_colname
def get_colname(self, colnum): """ Get the name associated with the given column number parameters ---------- colnum: integer The number for the column, zero offset """ if colnum < 0 or colnum > (len(self._colnames)-1): raise ValueError( ...
python
def get_colname(self, colnum): """ Get the name associated with the given column number parameters ---------- colnum: integer The number for the column, zero offset """ if colnum < 0 or colnum > (len(self._colnames)-1): raise ValueError( ...
[ "def", "get_colname", "(", "self", ",", "colnum", ")", ":", "if", "colnum", "<", "0", "or", "colnum", ">", "(", "len", "(", "self", ".", "_colnames", ")", "-", "1", ")", ":", "raise", "ValueError", "(", "\"colnum out of range [0,%s-1]\"", "%", "(", "0"...
Get the name associated with the given column number parameters ---------- colnum: integer The number for the column, zero offset
[ "Get", "the", "name", "associated", "with", "the", "given", "column", "number" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L84-L96
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.write
def write(self, data, **keys): """ Write data into this HDU parameters ---------- data: ndarray or list of ndarray A numerical python array. Should be an ordinary array for image HDUs, should have fields for tables. To write an ordinary array to ...
python
def write(self, data, **keys): """ Write data into this HDU parameters ---------- data: ndarray or list of ndarray A numerical python array. Should be an ordinary array for image HDUs, should have fields for tables. To write an ordinary array to ...
[ "def", "write", "(", "self", ",", "data", ",", "*", "*", "keys", ")", ":", "slow", "=", "keys", ".", "get", "(", "'slow'", ",", "False", ")", "isrec", "=", "False", "if", "isinstance", "(", "data", ",", "(", "list", ",", "dict", ")", ")", ":", ...
Write data into this HDU parameters ---------- data: ndarray or list of ndarray A numerical python array. Should be an ordinary array for image HDUs, should have fields for tables. To write an ordinary array to a column in a table HDU, use write_column. If...
[ "Write", "data", "into", "this", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L128-L240
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.write_column
def write_column(self, column, data, **keys): """ Write data to a column in this HDU This HDU must be a table HDU. parameters ---------- column: scalar string/integer The column in which to write. Can be the name or number (0 offset) column: ndarray...
python
def write_column(self, column, data, **keys): """ Write data to a column in this HDU This HDU must be a table HDU. parameters ---------- column: scalar string/integer The column in which to write. Can be the name or number (0 offset) column: ndarray...
[ "def", "write_column", "(", "self", ",", "column", ",", "data", ",", "*", "*", "keys", ")", ":", "firstrow", "=", "keys", ".", "get", "(", "'firstrow'", ",", "0", ")", "colnum", "=", "self", ".", "_extract_colnum", "(", "column", ")", "# need it to be ...
Write data to a column in this HDU This HDU must be a table HDU. parameters ---------- column: scalar string/integer The column in which to write. Can be the name or number (0 offset) column: ndarray Numerical python array to write. This should match t...
[ "Write", "data", "to", "a", "column", "in", "this", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L242-L290
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._verify_column_data
def _verify_column_data(self, colnum, data): """ verify the input data is of the correct type and shape """ this_dt = data.dtype.descr[0] if len(data.shape) > 2: this_shape = data.shape[1:] elif len(data.shape) == 2 and data.shape[1] > 1: this_sha...
python
def _verify_column_data(self, colnum, data): """ verify the input data is of the correct type and shape """ this_dt = data.dtype.descr[0] if len(data.shape) > 2: this_shape = data.shape[1:] elif len(data.shape) == 2 and data.shape[1] > 1: this_sha...
[ "def", "_verify_column_data", "(", "self", ",", "colnum", ",", "data", ")", ":", "this_dt", "=", "data", ".", "dtype", ".", "descr", "[", "0", "]", "if", "len", "(", "data", ".", "shape", ")", ">", "2", ":", "this_shape", "=", "data", ".", "shape",...
verify the input data is of the correct type and shape
[ "verify", "the", "input", "data", "is", "of", "the", "correct", "type", "and", "shape" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L292-L356
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.write_var_column
def write_var_column(self, column, data, firstrow=0, **keys): """ Write data to a variable-length column in this HDU This HDU must be a table HDU. parameters ---------- column: scalar string/integer The column in which to write. Can be the name or number (0...
python
def write_var_column(self, column, data, firstrow=0, **keys): """ Write data to a variable-length column in this HDU This HDU must be a table HDU. parameters ---------- column: scalar string/integer The column in which to write. Can be the name or number (0...
[ "def", "write_var_column", "(", "self", ",", "column", ",", "data", ",", "firstrow", "=", "0", ",", "*", "*", "keys", ")", ":", "if", "not", "is_object", "(", "data", ")", ":", "raise", "ValueError", "(", "\"Only object fields can be written to \"", "\"varia...
Write data to a variable-length column in this HDU This HDU must be a table HDU. parameters ---------- column: scalar string/integer The column in which to write. Can be the name or number (0 offset) column: ndarray Numerical python array to write. Thi...
[ "Write", "data", "to", "a", "variable", "-", "length", "column", "in", "this", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L358-L382
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.insert_column
def insert_column(self, name, data, colnum=None): """ Insert a new column. parameters ---------- name: string The column name data: The data to write into the new column. colnum: int, optional The column number for the new colu...
python
def insert_column(self, name, data, colnum=None): """ Insert a new column. parameters ---------- name: string The column name data: The data to write into the new column. colnum: int, optional The column number for the new colu...
[ "def", "insert_column", "(", "self", ",", "name", ",", "data", ",", "colnum", "=", "None", ")", ":", "if", "name", "in", "self", ".", "_colnames", ":", "raise", "ValueError", "(", "\"column '%s' already exists\"", "%", "name", ")", "if", "IS_PY3", "and", ...
Insert a new column. parameters ---------- name: string The column name data: The data to write into the new column. colnum: int, optional The column number for the new column, zero-offset. Default is to add the new column after t...
[ "Insert", "a", "new", "column", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L384-L439
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.append
def append(self, data, **keys): """ Append new rows to a table HDU parameters ---------- data: ndarray or list of arrays A numerical python array with fields (recarray) or a list of arrays. Should have the same fields as the existing table. If only ...
python
def append(self, data, **keys): """ Append new rows to a table HDU parameters ---------- data: ndarray or list of arrays A numerical python array with fields (recarray) or a list of arrays. Should have the same fields as the existing table. If only ...
[ "def", "append", "(", "self", ",", "data", ",", "*", "*", "keys", ")", ":", "firstrow", "=", "self", ".", "_info", "[", "'nrows'", "]", "keys", "[", "'firstrow'", "]", "=", "firstrow", "self", ".", "write", "(", "data", ",", "*", "*", "keys", ")"...
Append new rows to a table HDU parameters ---------- data: ndarray or list of arrays A numerical python array with fields (recarray) or a list of arrays. Should have the same fields as the existing table. If only a subset of the table columns are present, t...
[ "Append", "new", "rows", "to", "a", "table", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L441-L462
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.delete_rows
def delete_rows(self, rows): """ Delete rows from the table parameters ---------- rows: sequence or slice The exact rows to delete as a sequence, or a slice. examples -------- # delete a range of rows with fitsio.FITS(fname,'r...
python
def delete_rows(self, rows): """ Delete rows from the table parameters ---------- rows: sequence or slice The exact rows to delete as a sequence, or a slice. examples -------- # delete a range of rows with fitsio.FITS(fname,'r...
[ "def", "delete_rows", "(", "self", ",", "rows", ")", ":", "if", "rows", "is", "None", ":", "return", "# extract and convert to 1-offset for C routine", "if", "isinstance", "(", "rows", ",", "slice", ")", ":", "rows", "=", "self", ".", "_process_slice", "(", ...
Delete rows from the table parameters ---------- rows: sequence or slice The exact rows to delete as a sequence, or a slice. examples -------- # delete a range of rows with fitsio.FITS(fname,'rw') as fits: fits['mytable'].dele...
[ "Delete", "rows", "from", "the", "table" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L464-L513
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.resize
def resize(self, nrows, front=False): """ Resize the table to the given size, removing or adding rows as necessary. Note if expanding the table at the end, it is more efficient to use the append function than resizing and then writing. New added rows are zerod, except f...
python
def resize(self, nrows, front=False): """ Resize the table to the given size, removing or adding rows as necessary. Note if expanding the table at the end, it is more efficient to use the append function than resizing and then writing. New added rows are zerod, except f...
[ "def", "resize", "(", "self", ",", "nrows", ",", "front", "=", "False", ")", ":", "nrows_current", "=", "self", ".", "get_nrows", "(", ")", "if", "nrows", "==", "nrows_current", ":", "return", "if", "nrows", "<", "nrows_current", ":", "rowdiff", "=", "...
Resize the table to the given size, removing or adding rows as necessary. Note if expanding the table at the end, it is more efficient to use the append function than resizing and then writing. New added rows are zerod, except for 'i1', 'u2' and 'u4' data types which get -128,3...
[ "Resize", "the", "table", "to", "the", "given", "size", "removing", "or", "adding", "rows", "as", "necessary", ".", "Note", "if", "expanding", "the", "table", "at", "the", "end", "it", "is", "more", "efficient", "to", "use", "the", "append", "function", ...
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L515-L560
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.read
def read(self, **keys): """ read data from this HDU By default, all data are read. send columns= and rows= to select subsets of the data. Table data are read into a recarray; use read_column() to get a single column as an ordinary array. You can alternatively use slice...
python
def read(self, **keys): """ read data from this HDU By default, all data are read. send columns= and rows= to select subsets of the data. Table data are read into a recarray; use read_column() to get a single column as an ordinary array. You can alternatively use slice...
[ "def", "read", "(", "self", ",", "*", "*", "keys", ")", ":", "columns", "=", "keys", ".", "get", "(", "'columns'", ",", "None", ")", "rows", "=", "keys", ".", "get", "(", "'rows'", ",", "None", ")", "if", "columns", "is", "not", "None", ":", "i...
read data from this HDU By default, all data are read. send columns= and rows= to select subsets of the data. Table data are read into a recarray; use read_column() to get a single column as an ordinary array. You can alternatively use slice notation fits=fitsio.FITS(filen...
[ "read", "data", "from", "this", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L562-L606
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._read_all
def _read_all(self, **keys): """ Read all data in the HDU. parameters ---------- vstorage: string, optional Over-ride the default method to store variable length columns. Can be 'fixed' or 'object'. See docs on fitsio.FITS for details. lower: bo...
python
def _read_all(self, **keys): """ Read all data in the HDU. parameters ---------- vstorage: string, optional Over-ride the default method to store variable length columns. Can be 'fixed' or 'object'. See docs on fitsio.FITS for details. lower: bo...
[ "def", "_read_all", "(", "self", ",", "*", "*", "keys", ")", ":", "dtype", ",", "offsets", ",", "isvar", "=", "self", ".", "get_rec_dtype", "(", "*", "*", "keys", ")", "w", ",", "=", "numpy", ".", "where", "(", "isvar", "==", "True", ")", "# noqa...
Read all data in the HDU. parameters ---------- vstorage: string, optional Over-ride the default method to store variable length columns. Can be 'fixed' or 'object'. See docs on fitsio.FITS for details. lower: bool, optional If True, force all colum...
[ "Read", "all", "data", "in", "the", "HDU", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L608-L665
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.read_column
def read_column(self, col, **keys): """ Read the specified column Alternatively, you can use slice notation fits=fitsio.FITS(filename) fits[ext][colname][:] fits[ext][colname][2:5] fits[ext][colname][200:235:2] fits[ext][colname][rows]...
python
def read_column(self, col, **keys): """ Read the specified column Alternatively, you can use slice notation fits=fitsio.FITS(filename) fits[ext][colname][:] fits[ext][colname][2:5] fits[ext][colname][200:235:2] fits[ext][colname][rows]...
[ "def", "read_column", "(", "self", ",", "col", ",", "*", "*", "keys", ")", ":", "res", "=", "self", ".", "read_columns", "(", "[", "col", "]", ",", "*", "*", "keys", ")", "colname", "=", "res", ".", "dtype", ".", "names", "[", "0", "]", "data",...
Read the specified column Alternatively, you can use slice notation fits=fitsio.FITS(filename) fits[ext][colname][:] fits[ext][colname][2:5] fits[ext][colname][200:235:2] fits[ext][colname][rows] Note, if reading multiple columns, it is more ...
[ "Read", "the", "specified", "column" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L667-L697
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.read_rows
def read_rows(self, rows, **keys): """ Read the specified rows. parameters ---------- rows: list,array A list or array of row indices. vstorage: string, optional Over-ride the default method to store variable length columns. Can be 'f...
python
def read_rows(self, rows, **keys): """ Read the specified rows. parameters ---------- rows: list,array A list or array of row indices. vstorage: string, optional Over-ride the default method to store variable length columns. Can be 'f...
[ "def", "read_rows", "(", "self", ",", "rows", ",", "*", "*", "keys", ")", ":", "if", "rows", "is", "None", ":", "# we actually want all rows!", "return", "self", ".", "_read_all", "(", ")", "if", "self", ".", "_info", "[", "'hdutype'", "]", "==", "ASCI...
Read the specified rows. parameters ---------- rows: list,array A list or array of row indices. vstorage: string, optional Over-ride the default method to store variable length columns. Can be 'fixed' or 'object'. See docs on fitsio.FITS for details...
[ "Read", "the", "specified", "rows", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L699-L756
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.read_columns
def read_columns(self, columns, **keys): """ read a subset of columns from this binary table HDU By default, all rows are read. Send rows= to select subsets of the data. Table data are read into a recarray for multiple columns, plain array for a single column. paramet...
python
def read_columns(self, columns, **keys): """ read a subset of columns from this binary table HDU By default, all rows are read. Send rows= to select subsets of the data. Table data are read into a recarray for multiple columns, plain array for a single column. paramet...
[ "def", "read_columns", "(", "self", ",", "columns", ",", "*", "*", "keys", ")", ":", "if", "self", ".", "_info", "[", "'hdutype'", "]", "==", "ASCII_TBL", ":", "keys", "[", "'columns'", "]", "=", "columns", "return", "self", ".", "read", "(", "*", ...
read a subset of columns from this binary table HDU By default, all rows are read. Send rows= to select subsets of the data. Table data are read into a recarray for multiple columns, plain array for a single column. parameters ---------- columns: list/array ...
[ "read", "a", "subset", "of", "columns", "from", "this", "binary", "table", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L758-L845
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.read_slice
def read_slice(self, firstrow, lastrow, step=1, **keys): """ Read the specified row slice from a table. Read all rows between firstrow and lastrow (non-inclusive, as per python slice notation). Note you must use slice notation for images, e.g. f[ext][20:30, 40:50] para...
python
def read_slice(self, firstrow, lastrow, step=1, **keys): """ Read the specified row slice from a table. Read all rows between firstrow and lastrow (non-inclusive, as per python slice notation). Note you must use slice notation for images, e.g. f[ext][20:30, 40:50] para...
[ "def", "read_slice", "(", "self", ",", "firstrow", ",", "lastrow", ",", "step", "=", "1", ",", "*", "*", "keys", ")", ":", "if", "self", ".", "_info", "[", "'hdutype'", "]", "==", "ASCII_TBL", ":", "rows", "=", "numpy", ".", "arange", "(", "firstro...
Read the specified row slice from a table. Read all rows between firstrow and lastrow (non-inclusive, as per python slice notation). Note you must use slice notation for images, e.g. f[ext][20:30, 40:50] parameters ---------- firstrow: integer The first row...
[ "Read", "the", "specified", "row", "slice", "from", "a", "table", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L847-L931
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.get_rec_dtype
def get_rec_dtype(self, **keys): """ Get the dtype for the specified columns parameters ---------- colnums: integer array The column numbers, 0 offset vstorage: string, optional See docs in read_columns """ colnums = keys.get('coln...
python
def get_rec_dtype(self, **keys): """ Get the dtype for the specified columns parameters ---------- colnums: integer array The column numbers, 0 offset vstorage: string, optional See docs in read_columns """ colnums = keys.get('coln...
[ "def", "get_rec_dtype", "(", "self", ",", "*", "*", "keys", ")", ":", "colnums", "=", "keys", ".", "get", "(", "'colnums'", ",", "None", ")", "vstorage", "=", "keys", ".", "get", "(", "'vstorage'", ",", "self", ".", "_vstorage", ")", "if", "colnums",...
Get the dtype for the specified columns parameters ---------- colnums: integer array The column numbers, 0 offset vstorage: string, optional See docs in read_columns
[ "Get", "the", "dtype", "for", "the", "specified", "columns" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L933-L961
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._check_tbit
def _check_tbit(self, **keys): """ Check if one of the columns is a TBIT column parameters ---------- colnums: integer array, optional """ colnums = keys.get('colnums', None) if colnums is None: colnums = self._extract_colnums() has_...
python
def _check_tbit(self, **keys): """ Check if one of the columns is a TBIT column parameters ---------- colnums: integer array, optional """ colnums = keys.get('colnums', None) if colnums is None: colnums = self._extract_colnums() has_...
[ "def", "_check_tbit", "(", "self", ",", "*", "*", "keys", ")", ":", "colnums", "=", "keys", ".", "get", "(", "'colnums'", ",", "None", ")", "if", "colnums", "is", "None", ":", "colnums", "=", "self", ".", "_extract_colnums", "(", ")", "has_tbit", "="...
Check if one of the columns is a TBIT column parameters ---------- colnums: integer array, optional
[ "Check", "if", "one", "of", "the", "columns", "is", "a", "TBIT", "column" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L963-L983
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._fix_tbit_dtype
def _fix_tbit_dtype(self, array, colnums): """ If necessary, patch up the TBIT to convert to bool array parameters ---------- array: record array colnums: column numbers for lookup """ descr = array.dtype.descr for i, colnum in enumerate(colnums):...
python
def _fix_tbit_dtype(self, array, colnums): """ If necessary, patch up the TBIT to convert to bool array parameters ---------- array: record array colnums: column numbers for lookup """ descr = array.dtype.descr for i, colnum in enumerate(colnums):...
[ "def", "_fix_tbit_dtype", "(", "self", ",", "array", ",", "colnums", ")", ":", "descr", "=", "array", ".", "dtype", ".", "descr", "for", "i", ",", "colnum", "in", "enumerate", "(", "colnums", ")", ":", "npy_type", ",", "isvar", ",", "istbit", "=", "s...
If necessary, patch up the TBIT to convert to bool array parameters ---------- array: record array colnums: column numbers for lookup
[ "If", "necessary", "patch", "up", "the", "TBIT", "to", "convert", "to", "bool", "array" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L985-L1002
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._get_simple_dtype_and_shape
def _get_simple_dtype_and_shape(self, colnum, rows=None): """ When reading a single column, we want the basic data type and the shape of the array. for scalar columns, shape is just nrows, otherwise it is (nrows, dim1, dim2) Note if rows= is sent and only a single row i...
python
def _get_simple_dtype_and_shape(self, colnum, rows=None): """ When reading a single column, we want the basic data type and the shape of the array. for scalar columns, shape is just nrows, otherwise it is (nrows, dim1, dim2) Note if rows= is sent and only a single row i...
[ "def", "_get_simple_dtype_and_shape", "(", "self", ",", "colnum", ",", "rows", "=", "None", ")", ":", "# basic datatype", "npy_type", ",", "isvar", ",", "istbit", "=", "self", ".", "_get_tbl_numpy_dtype", "(", "colnum", ")", "info", "=", "self", ".", "_info"...
When reading a single column, we want the basic data type and the shape of the array. for scalar columns, shape is just nrows, otherwise it is (nrows, dim1, dim2) Note if rows= is sent and only a single row is requested, the shape will be (dim2,dim2)
[ "When", "reading", "a", "single", "column", "we", "want", "the", "basic", "data", "type", "and", "the", "shape", "of", "the", "array", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1004-L1041
esheldon/fitsio
fitsio/hdu/table.py
TableHDU.get_rec_column_descr
def get_rec_column_descr(self, colnum, vstorage): """ Get a descriptor entry for the specified column. parameters ---------- colnum: integer The column number, 0 offset vstorage: string See docs in read_columns """ npy_type, isvar,...
python
def get_rec_column_descr(self, colnum, vstorage): """ Get a descriptor entry for the specified column. parameters ---------- colnum: integer The column number, 0 offset vstorage: string See docs in read_columns """ npy_type, isvar,...
[ "def", "get_rec_column_descr", "(", "self", ",", "colnum", ",", "vstorage", ")", ":", "npy_type", ",", "isvar", ",", "istbit", "=", "self", ".", "_get_tbl_numpy_dtype", "(", "colnum", ")", "name", "=", "self", ".", "_info", "[", "'colinfo'", "]", "[", "c...
Get a descriptor entry for the specified column. parameters ---------- colnum: integer The column number, 0 offset vstorage: string See docs in read_columns
[ "Get", "a", "descriptor", "entry", "for", "the", "specified", "column", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1043-L1100
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._read_rec_with_var
def _read_rec_with_var( self, colnums, rows, dtype, offsets, isvar, vstorage): """ Read columns from a table into a rec array, including variable length columns. This is special because, for efficiency, it involves reading from the main table as normal but skipping the colum...
python
def _read_rec_with_var( self, colnums, rows, dtype, offsets, isvar, vstorage): """ Read columns from a table into a rec array, including variable length columns. This is special because, for efficiency, it involves reading from the main table as normal but skipping the colum...
[ "def", "_read_rec_with_var", "(", "self", ",", "colnums", ",", "rows", ",", "dtype", ",", "offsets", ",", "isvar", ",", "vstorage", ")", ":", "colnumsp", "=", "colnums", "+", "1", "if", "rows", "is", "None", ":", "nrows", "=", "self", ".", "_info", "...
Read columns from a table into a rec array, including variable length columns. This is special because, for efficiency, it involves reading from the main table as normal but skipping the columns in the array that are variable. Then reading the variable length columns, with accounting f...
[ "Read", "columns", "from", "a", "table", "into", "a", "rec", "array", "including", "variable", "length", "columns", ".", "This", "is", "special", "because", "for", "efficiency", "it", "involves", "reading", "from", "the", "main", "table", "as", "normal", "bu...
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1102-L1188
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._extract_rows
def _extract_rows(self, rows): """ Extract an array of rows from an input scalar or sequence """ if rows is not None: rows = numpy.array(rows, ndmin=1, copy=False, dtype='i8') # returns unique, sorted rows = numpy.unique(rows) maxrow = sel...
python
def _extract_rows(self, rows): """ Extract an array of rows from an input scalar or sequence """ if rows is not None: rows = numpy.array(rows, ndmin=1, copy=False, dtype='i8') # returns unique, sorted rows = numpy.unique(rows) maxrow = sel...
[ "def", "_extract_rows", "(", "self", ",", "rows", ")", ":", "if", "rows", "is", "not", "None", ":", "rows", "=", "numpy", ".", "array", "(", "rows", ",", "ndmin", "=", "1", ",", "copy", "=", "False", ",", "dtype", "=", "'i8'", ")", "# returns uniqu...
Extract an array of rows from an input scalar or sequence
[ "Extract", "an", "array", "of", "rows", "from", "an", "input", "scalar", "or", "sequence" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1190-L1202
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._process_slice
def _process_slice(self, arg): """ process the input slice for use calling the C code """ start = arg.start stop = arg.stop step = arg.step nrows = self._info['nrows'] if step is None: step = 1 if start is None: start = 0 ...
python
def _process_slice(self, arg): """ process the input slice for use calling the C code """ start = arg.start stop = arg.stop step = arg.step nrows = self._info['nrows'] if step is None: step = 1 if start is None: start = 0 ...
[ "def", "_process_slice", "(", "self", ",", "arg", ")", ":", "start", "=", "arg", ".", "start", "stop", "=", "arg", ".", "stop", "step", "=", "arg", ".", "step", "nrows", "=", "self", ".", "_info", "[", "'nrows'", "]", "if", "step", "is", "None", ...
process the input slice for use calling the C code
[ "process", "the", "input", "slice", "for", "use", "calling", "the", "C", "code" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1204-L1234
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._slice2rows
def _slice2rows(self, start, stop, step=None): """ Convert a slice to an explicit array of rows """ nrows = self._info['nrows'] if start is None: start = 0 if stop is None: stop = nrows if step is None: step = 1 tstart ...
python
def _slice2rows(self, start, stop, step=None): """ Convert a slice to an explicit array of rows """ nrows = self._info['nrows'] if start is None: start = 0 if stop is None: stop = nrows if step is None: step = 1 tstart ...
[ "def", "_slice2rows", "(", "self", ",", "start", ",", "stop", ",", "step", "=", "None", ")", ":", "nrows", "=", "self", ".", "_info", "[", "'nrows'", "]", "if", "start", "is", "None", ":", "start", "=", "0", "if", "stop", "is", "None", ":", "stop...
Convert a slice to an explicit array of rows
[ "Convert", "a", "slice", "to", "an", "explicit", "array", "of", "rows" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1236-L1256
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._fix_range
def _fix_range(self, num, isslice=True): """ Ensure the input is within range. If el=True, then don't treat as a slice element """ nrows = self._info['nrows'] if isslice: # include the end if num < 0: num = nrows + (1+num) ...
python
def _fix_range(self, num, isslice=True): """ Ensure the input is within range. If el=True, then don't treat as a slice element """ nrows = self._info['nrows'] if isslice: # include the end if num < 0: num = nrows + (1+num) ...
[ "def", "_fix_range", "(", "self", ",", "num", ",", "isslice", "=", "True", ")", ":", "nrows", "=", "self", ".", "_info", "[", "'nrows'", "]", "if", "isslice", ":", "# include the end", "if", "num", "<", "0", ":", "num", "=", "nrows", "+", "(", "1",...
Ensure the input is within range. If el=True, then don't treat as a slice element
[ "Ensure", "the", "input", "is", "within", "range", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1258-L1279
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._rescale_and_convert_field_inplace
def _rescale_and_convert_field_inplace(self, array, name, scale, zero): """ Apply fits scalings. Also, convert bool to proper numpy boolean values """ self._rescale_array(array[name], scale, zero) if array[name].dtype == numpy.bool: array[name] = self._conver...
python
def _rescale_and_convert_field_inplace(self, array, name, scale, zero): """ Apply fits scalings. Also, convert bool to proper numpy boolean values """ self._rescale_array(array[name], scale, zero) if array[name].dtype == numpy.bool: array[name] = self._conver...
[ "def", "_rescale_and_convert_field_inplace", "(", "self", ",", "array", ",", "name", ",", "scale", ",", "zero", ")", ":", "self", ".", "_rescale_array", "(", "array", "[", "name", "]", ",", "scale", ",", "zero", ")", "if", "array", "[", "name", "]", "....
Apply fits scalings. Also, convert bool to proper numpy boolean values
[ "Apply", "fits", "scalings", ".", "Also", "convert", "bool", "to", "proper", "numpy", "boolean", "values" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1281-L1289
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._rescale_array
def _rescale_array(self, array, scale, zero): """ Scale the input array """ if scale != 1.0: sval = numpy.array(scale, dtype=array.dtype) array *= sval if zero != 0.0: zval = numpy.array(zero, dtype=array.dtype) array += zval
python
def _rescale_array(self, array, scale, zero): """ Scale the input array """ if scale != 1.0: sval = numpy.array(scale, dtype=array.dtype) array *= sval if zero != 0.0: zval = numpy.array(zero, dtype=array.dtype) array += zval
[ "def", "_rescale_array", "(", "self", ",", "array", ",", "scale", ",", "zero", ")", ":", "if", "scale", "!=", "1.0", ":", "sval", "=", "numpy", ".", "array", "(", "scale", ",", "dtype", "=", "array", ".", "dtype", ")", "array", "*=", "sval", "if", ...
Scale the input array
[ "Scale", "the", "input", "array" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1302-L1311
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._maybe_trim_strings
def _maybe_trim_strings(self, array, **keys): """ if requested, trim trailing white space from all string fields in the input array """ trim_strings = keys.get('trim_strings', False) if self.trim_strings or trim_strings: _trim_strings(array)
python
def _maybe_trim_strings(self, array, **keys): """ if requested, trim trailing white space from all string fields in the input array """ trim_strings = keys.get('trim_strings', False) if self.trim_strings or trim_strings: _trim_strings(array)
[ "def", "_maybe_trim_strings", "(", "self", ",", "array", ",", "*", "*", "keys", ")", ":", "trim_strings", "=", "keys", ".", "get", "(", "'trim_strings'", ",", "False", ")", "if", "self", ".", "trim_strings", "or", "trim_strings", ":", "_trim_strings", "(",...
if requested, trim trailing white space from all string fields in the input array
[ "if", "requested", "trim", "trailing", "white", "space", "from", "all", "string", "fields", "in", "the", "input", "array" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1313-L1320
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._convert_bool_array
def _convert_bool_array(self, array): """ cfitsio reads as characters 'T' and 'F' -- convert to real boolean If input is a fits bool, convert to numpy boolean """ output = (array.view(numpy.int8) == ord('T')).astype(numpy.bool) return output
python
def _convert_bool_array(self, array): """ cfitsio reads as characters 'T' and 'F' -- convert to real boolean If input is a fits bool, convert to numpy boolean """ output = (array.view(numpy.int8) == ord('T')).astype(numpy.bool) return output
[ "def", "_convert_bool_array", "(", "self", ",", "array", ")", ":", "output", "=", "(", "array", ".", "view", "(", "numpy", ".", "int8", ")", "==", "ord", "(", "'T'", ")", ")", ".", "astype", "(", "numpy", ".", "bool", ")", "return", "output" ]
cfitsio reads as characters 'T' and 'F' -- convert to real boolean If input is a fits bool, convert to numpy boolean
[ "cfitsio", "reads", "as", "characters", "T", "and", "F", "--", "convert", "to", "real", "boolean", "If", "input", "is", "a", "fits", "bool", "convert", "to", "numpy", "boolean" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1344-L1351
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._get_tbl_numpy_dtype
def _get_tbl_numpy_dtype(self, colnum, include_endianness=True): """ Get numpy type for the input column """ table_type = self._info['hdutype'] table_type_string = _hdu_type_map[table_type] try: ftype = self._info['colinfo'][colnum]['eqtype'] if ta...
python
def _get_tbl_numpy_dtype(self, colnum, include_endianness=True): """ Get numpy type for the input column """ table_type = self._info['hdutype'] table_type_string = _hdu_type_map[table_type] try: ftype = self._info['colinfo'][colnum]['eqtype'] if ta...
[ "def", "_get_tbl_numpy_dtype", "(", "self", ",", "colnum", ",", "include_endianness", "=", "True", ")", ":", "table_type", "=", "self", ".", "_info", "[", "'hdutype'", "]", "table_type_string", "=", "_hdu_type_map", "[", "table_type", "]", "try", ":", "ftype",...
Get numpy type for the input column
[ "Get", "numpy", "type", "for", "the", "input", "column" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1353-L1393
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._process_args_as_rows_or_columns
def _process_args_as_rows_or_columns(self, arg, unpack=False): """ We must be able to interpret the args as as either a column name or row number, or sequences thereof. Numpy arrays and slices are also fine. Examples: 'field' 35 [35,55,86] ...
python
def _process_args_as_rows_or_columns(self, arg, unpack=False): """ We must be able to interpret the args as as either a column name or row number, or sequences thereof. Numpy arrays and slices are also fine. Examples: 'field' 35 [35,55,86] ...
[ "def", "_process_args_as_rows_or_columns", "(", "self", ",", "arg", ",", "unpack", "=", "False", ")", ":", "flags", "=", "set", "(", ")", "#", "if", "isinstance", "(", "arg", ",", "(", "tuple", ",", "list", ",", "numpy", ".", "ndarray", ")", ")", ":"...
We must be able to interpret the args as as either a column name or row number, or sequences thereof. Numpy arrays and slices are also fine. Examples: 'field' 35 [35,55,86] ['f1',f2',...] Can also be tuples or arrays.
[ "We", "must", "be", "able", "to", "interpret", "the", "args", "as", "as", "either", "a", "column", "name", "or", "row", "number", "or", "sequences", "thereof", ".", "Numpy", "arrays", "and", "slices", "are", "also", "fine", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1395-L1437
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._extract_colnums
def _extract_colnums(self, columns=None): """ Extract an array of columns from the input """ if columns is None: return numpy.arange(self._ncol, dtype='i8') if not isinstance(columns, (tuple, list, numpy.ndarray)): # is a scalar return self._e...
python
def _extract_colnums(self, columns=None): """ Extract an array of columns from the input """ if columns is None: return numpy.arange(self._ncol, dtype='i8') if not isinstance(columns, (tuple, list, numpy.ndarray)): # is a scalar return self._e...
[ "def", "_extract_colnums", "(", "self", ",", "columns", "=", "None", ")", ":", "if", "columns", "is", "None", ":", "return", "numpy", ".", "arange", "(", "self", ".", "_ncol", ",", "dtype", "=", "'i8'", ")", "if", "not", "isinstance", "(", "columns", ...
Extract an array of columns from the input
[ "Extract", "an", "array", "of", "columns", "from", "the", "input" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1494-L1511
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._extract_colnum
def _extract_colnum(self, col): """ Get the column number for the input column """ if isinteger(col): colnum = col if (colnum < 0) or (colnum > (self._ncol-1)): raise ValueError( "column number should be in [0,%d]" % (0, self._...
python
def _extract_colnum(self, col): """ Get the column number for the input column """ if isinteger(col): colnum = col if (colnum < 0) or (colnum > (self._ncol-1)): raise ValueError( "column number should be in [0,%d]" % (0, self._...
[ "def", "_extract_colnum", "(", "self", ",", "col", ")", ":", "if", "isinteger", "(", "col", ")", ":", "colnum", "=", "col", "if", "(", "colnum", "<", "0", ")", "or", "(", "colnum", ">", "(", "self", ".", "_ncol", "-", "1", ")", ")", ":", "raise...
Get the column number for the input column
[ "Get", "the", "column", "number", "for", "the", "input", "column" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1513-L1535
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._update_info
def _update_info(self): """ Call parent method and make sure this is in fact a table HDU. Set some convenience data. """ super(TableHDU, self)._update_info() if self._info['hdutype'] == IMAGE_HDU: mess = "Extension %s is not a Table HDU" % self.ext ...
python
def _update_info(self): """ Call parent method and make sure this is in fact a table HDU. Set some convenience data. """ super(TableHDU, self)._update_info() if self._info['hdutype'] == IMAGE_HDU: mess = "Extension %s is not a Table HDU" % self.ext ...
[ "def", "_update_info", "(", "self", ")", ":", "super", "(", "TableHDU", ",", "self", ")", ".", "_update_info", "(", ")", "if", "self", ".", "_info", "[", "'hdutype'", "]", "==", "IMAGE_HDU", ":", "mess", "=", "\"Extension %s is not a Table HDU\"", "%", "se...
Call parent method and make sure this is in fact a table HDU. Set some convenience data.
[ "Call", "parent", "method", "and", "make", "sure", "this", "is", "in", "fact", "a", "table", "HDU", ".", "Set", "some", "convenience", "data", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1537-L1550
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._get_next_buffered_row
def _get_next_buffered_row(self): """ Get the next row for iteration. """ if self._iter_row == self._iter_nrows: raise StopIteration if self._row_buffer_index >= self._iter_row_buffer: self._buffer_iter_rows(self._iter_row) data = self._row_buffe...
python
def _get_next_buffered_row(self): """ Get the next row for iteration. """ if self._iter_row == self._iter_nrows: raise StopIteration if self._row_buffer_index >= self._iter_row_buffer: self._buffer_iter_rows(self._iter_row) data = self._row_buffe...
[ "def", "_get_next_buffered_row", "(", "self", ")", ":", "if", "self", ".", "_iter_row", "==", "self", ".", "_iter_nrows", ":", "raise", "StopIteration", "if", "self", ".", "_row_buffer_index", ">=", "self", ".", "_iter_row_buffer", ":", "self", ".", "_buffer_i...
Get the next row for iteration.
[ "Get", "the", "next", "row", "for", "iteration", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1640-L1653
esheldon/fitsio
fitsio/hdu/table.py
TableHDU._buffer_iter_rows
def _buffer_iter_rows(self, start): """ Read in the buffer for iteration """ self._row_buffer = self[start:start+self._iter_row_buffer] # start back at the front of the buffer self._row_buffer_index = 0
python
def _buffer_iter_rows(self, start): """ Read in the buffer for iteration """ self._row_buffer = self[start:start+self._iter_row_buffer] # start back at the front of the buffer self._row_buffer_index = 0
[ "def", "_buffer_iter_rows", "(", "self", ",", "start", ")", ":", "self", ".", "_row_buffer", "=", "self", "[", "start", ":", "start", "+", "self", ".", "_iter_row_buffer", "]", "# start back at the front of the buffer", "self", ".", "_row_buffer_index", "=", "0"...
Read in the buffer for iteration
[ "Read", "in", "the", "buffer", "for", "iteration" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1655-L1662
esheldon/fitsio
fitsio/hdu/table.py
AsciiTableHDU.read
def read(self, **keys): """ read a data from an ascii table HDU By default, all rows are read. Send rows= to select subsets of the data. Table data are read into a recarray for multiple columns, plain array for a single column. parameters ---------- co...
python
def read(self, **keys): """ read a data from an ascii table HDU By default, all rows are read. Send rows= to select subsets of the data. Table data are read into a recarray for multiple columns, plain array for a single column. parameters ---------- co...
[ "def", "read", "(", "self", ",", "*", "*", "keys", ")", ":", "rows", "=", "keys", ".", "get", "(", "'rows'", ",", "None", ")", "columns", "=", "keys", ".", "get", "(", "'columns'", ",", "None", ")", "# if columns is None, returns all. Guaranteed to be uni...
read a data from an ascii table HDU By default, all rows are read. Send rows= to select subsets of the data. Table data are read into a recarray for multiple columns, plain array for a single column. parameters ---------- columns: list/array An optional se...
[ "read", "a", "data", "from", "an", "ascii", "table", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1713-L1816
esheldon/fitsio
fitsio/hdu/table.py
TableColumnSubset.read
def read(self, **keys): """ Read the data from disk and return as a numpy array """ if self.is_scalar: data = self.fitshdu.read_column(self.columns, **keys) else: c = keys.get('columns', None) if c is None: keys['columns'] = se...
python
def read(self, **keys): """ Read the data from disk and return as a numpy array """ if self.is_scalar: data = self.fitshdu.read_column(self.columns, **keys) else: c = keys.get('columns', None) if c is None: keys['columns'] = se...
[ "def", "read", "(", "self", ",", "*", "*", "keys", ")", ":", "if", "self", ".", "is_scalar", ":", "data", "=", "self", ".", "fitshdu", ".", "read_column", "(", "self", ".", "columns", ",", "*", "*", "keys", ")", "else", ":", "c", "=", "keys", "...
Read the data from disk and return as a numpy array
[ "Read", "the", "data", "from", "disk", "and", "return", "as", "a", "numpy", "array" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/table.py#L1868-L1881
esheldon/fitsio
fitsio/fitslib.py
read
def read(filename, ext=None, extver=None, **keys): """ Convenience function to read data from the specified FITS HDU By default, all data are read. For tables, send columns= and rows= to select subsets of the data. Table data are read into a recarray; use a FITS object and read_column() to get a ...
python
def read(filename, ext=None, extver=None, **keys): """ Convenience function to read data from the specified FITS HDU By default, all data are read. For tables, send columns= and rows= to select subsets of the data. Table data are read into a recarray; use a FITS object and read_column() to get a ...
[ "def", "read", "(", "filename", ",", "ext", "=", "None", ",", "extver", "=", "None", ",", "*", "*", "keys", ")", ":", "with", "FITS", "(", "filename", ",", "*", "*", "keys", ")", "as", "fits", ":", "header", "=", "keys", ".", "pop", "(", "'head...
Convenience function to read data from the specified FITS HDU By default, all data are read. For tables, send columns= and rows= to select subsets of the data. Table data are read into a recarray; use a FITS object and read_column() to get a single column as an ordinary array. For images, create a FI...
[ "Convenience", "function", "to", "read", "data", "from", "the", "specified", "FITS", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L51-L117
esheldon/fitsio
fitsio/fitslib.py
read_header
def read_header(filename, ext=0, extver=None, case_sensitive=False, **keys): """ Convenience function to read the header from the specified FITS HDU The FITSHDR allows access to the values and comments by name and number. parameters ---------- filename: string A filename. ext: ...
python
def read_header(filename, ext=0, extver=None, case_sensitive=False, **keys): """ Convenience function to read the header from the specified FITS HDU The FITSHDR allows access to the values and comments by name and number. parameters ---------- filename: string A filename. ext: ...
[ "def", "read_header", "(", "filename", ",", "ext", "=", "0", ",", "extver", "=", "None", ",", "case_sensitive", "=", "False", ",", "*", "*", "keys", ")", ":", "dont_create", "=", "0", "try", ":", "hdunum", "=", "ext", "+", "1", "except", "TypeError",...
Convenience function to read the header from the specified FITS HDU The FITSHDR allows access to the values and comments by name and number. parameters ---------- filename: string A filename. ext: number or string, optional The extension. Either the numerical extension from ze...
[ "Convenience", "function", "to", "read", "the", "header", "from", "the", "specified", "FITS", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L120-L190
esheldon/fitsio
fitsio/fitslib.py
read_scamp_head
def read_scamp_head(fname, header=None): """ read a SCAMP .head file as a fits header FITSHDR object parameters ---------- fname: string The path to the SCAMP .head file header: FITSHDR, optional Optionally combine the header with the input one. The input can be any obj...
python
def read_scamp_head(fname, header=None): """ read a SCAMP .head file as a fits header FITSHDR object parameters ---------- fname: string The path to the SCAMP .head file header: FITSHDR, optional Optionally combine the header with the input one. The input can be any obj...
[ "def", "read_scamp_head", "(", "fname", ",", "header", "=", "None", ")", ":", "with", "open", "(", "fname", ")", "as", "fobj", ":", "lines", "=", "fobj", ".", "readlines", "(", ")", "lines", "=", "[", "l", ".", "strip", "(", ")", "for", "l", "in"...
read a SCAMP .head file as a fits header FITSHDR object parameters ---------- fname: string The path to the SCAMP .head file header: FITSHDR, optional Optionally combine the header with the input one. The input can be any object convertable to a FITSHDR object returns ...
[ "read", "a", "SCAMP", ".", "head", "file", "as", "a", "fits", "header", "FITSHDR", "object" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L193-L223
esheldon/fitsio
fitsio/fitslib.py
write
def write(filename, data, extname=None, extver=None, units=None, compress=None, table_type='binary', header=None, clobber=False, **keys): """ Convenience function to create a new HDU and write the data. Under the hood, a FITS object is constructed. If you want to append rows to an ...
python
def write(filename, data, extname=None, extver=None, units=None, compress=None, table_type='binary', header=None, clobber=False, **keys): """ Convenience function to create a new HDU and write the data. Under the hood, a FITS object is constructed. If you want to append rows to an ...
[ "def", "write", "(", "filename", ",", "data", ",", "extname", "=", "None", ",", "extver", "=", "None", ",", "units", "=", "None", ",", "compress", "=", "None", ",", "table_type", "=", "'binary'", ",", "header", "=", "None", ",", "clobber", "=", "Fals...
Convenience function to create a new HDU and write the data. Under the hood, a FITS object is constructed. If you want to append rows to an existing HDU, or modify data in an HDU, please construct a FITS object. parameters ---------- filename: string A filename. data: Eith...
[ "Convenience", "function", "to", "create", "a", "new", "HDU", "and", "write", "the", "data", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L236-L317
esheldon/fitsio
fitsio/fitslib.py
array2tabledef
def array2tabledef(data, table_type='binary', write_bitcols=False): """ Similar to descr2tabledef but if there are object columns a type and max length will be extracted and used for the tabledef """ is_ascii = (table_type == 'ascii') if data.dtype.fields is None: raise ValueError("data...
python
def array2tabledef(data, table_type='binary', write_bitcols=False): """ Similar to descr2tabledef but if there are object columns a type and max length will be extracted and used for the tabledef """ is_ascii = (table_type == 'ascii') if data.dtype.fields is None: raise ValueError("data...
[ "def", "array2tabledef", "(", "data", ",", "table_type", "=", "'binary'", ",", "write_bitcols", "=", "False", ")", ":", "is_ascii", "=", "(", "table_type", "==", "'ascii'", ")", "if", "data", ".", "dtype", ".", "fields", "is", "None", ":", "raise", "Valu...
Similar to descr2tabledef but if there are object columns a type and max length will be extracted and used for the tabledef
[ "Similar", "to", "descr2tabledef", "but", "if", "there", "are", "object", "columns", "a", "type", "and", "max", "length", "will", "be", "extracted", "and", "used", "for", "the", "tabledef" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1237-L1298
esheldon/fitsio
fitsio/fitslib.py
descr2tabledef
def descr2tabledef(descr, table_type='binary', write_bitcols=False): """ Create a FITS table def from the input numpy descriptor. parameters ---------- descr: list A numpy recarray type descriptor array.dtype.descr returns ------- names, formats, dims: tuple of lists T...
python
def descr2tabledef(descr, table_type='binary', write_bitcols=False): """ Create a FITS table def from the input numpy descriptor. parameters ---------- descr: list A numpy recarray type descriptor array.dtype.descr returns ------- names, formats, dims: tuple of lists T...
[ "def", "descr2tabledef", "(", "descr", ",", "table_type", "=", "'binary'", ",", "write_bitcols", "=", "False", ")", ":", "names", "=", "[", "]", "formats", "=", "[", "]", "dims", "=", "[", "]", "for", "d", "in", "descr", ":", "\"\"\"\n npy_dtype =...
Create a FITS table def from the input numpy descriptor. parameters ---------- descr: list A numpy recarray type descriptor array.dtype.descr returns ------- names, formats, dims: tuple of lists These are the ttyp, tform and tdim header entries for each field. dim ent...
[ "Create", "a", "FITS", "table", "def", "from", "the", "input", "numpy", "descriptor", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1356-L1406
esheldon/fitsio
fitsio/fitslib.py
get_tile_dims
def get_tile_dims(tile_dims, imshape): """ Just make sure the tile dims has the appropriate number of dimensions """ if tile_dims is None: td = None else: td = numpy.array(tile_dims, dtype='i8') nd = len(imshape) if td.size != nd: msg = "expected tile_dim...
python
def get_tile_dims(tile_dims, imshape): """ Just make sure the tile dims has the appropriate number of dimensions """ if tile_dims is None: td = None else: td = numpy.array(tile_dims, dtype='i8') nd = len(imshape) if td.size != nd: msg = "expected tile_dim...
[ "def", "get_tile_dims", "(", "tile_dims", ",", "imshape", ")", ":", "if", "tile_dims", "is", "None", ":", "td", "=", "None", "else", ":", "td", "=", "numpy", ".", "array", "(", "tile_dims", ",", "dtype", "=", "'i8'", ")", "nd", "=", "len", "(", "im...
Just make sure the tile dims has the appropriate number of dimensions
[ "Just", "make", "sure", "the", "tile", "dims", "has", "the", "appropriate", "number", "of", "dimensions" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1452-L1466
esheldon/fitsio
fitsio/fitslib.py
_extract_table_type
def _extract_table_type(type): """ Get the numerical table type """ if isinstance(type, str): type = type.lower() if type[0:7] == 'binary': table_type = BINARY_TBL elif type[0:6] == 'ascii': table_type = ASCII_TBL else: raise ValueError...
python
def _extract_table_type(type): """ Get the numerical table type """ if isinstance(type, str): type = type.lower() if type[0:7] == 'binary': table_type = BINARY_TBL elif type[0:6] == 'ascii': table_type = ASCII_TBL else: raise ValueError...
[ "def", "_extract_table_type", "(", "type", ")", ":", "if", "isinstance", "(", "type", ",", "str", ")", ":", "type", "=", "type", ".", "lower", "(", ")", "if", "type", "[", "0", ":", "7", "]", "==", "'binary'", ":", "table_type", "=", "BINARY_TBL", ...
Get the numerical table type
[ "Get", "the", "numerical", "table", "type" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1496-L1518
esheldon/fitsio
fitsio/fitslib.py
FITS.close
def close(self): """ Close the fits file and set relevant metadata to None """ if hasattr(self, '_FITS'): if self._FITS is not None: self._FITS.close() self._FITS = None self._filename = None self.mode = None self.charmo...
python
def close(self): """ Close the fits file and set relevant metadata to None """ if hasattr(self, '_FITS'): if self._FITS is not None: self._FITS.close() self._FITS = None self._filename = None self.mode = None self.charmo...
[ "def", "close", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_FITS'", ")", ":", "if", "self", ".", "_FITS", "is", "not", "None", ":", "self", ".", "_FITS", ".", "close", "(", ")", "self", ".", "_FITS", "=", "None", "self", ".", "...
Close the fits file and set relevant metadata to None
[ "Close", "the", "fits", "file", "and", "set", "relevant", "metadata", "to", "None" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L409-L422
esheldon/fitsio
fitsio/fitslib.py
FITS.movnam_hdu
def movnam_hdu(self, extname, hdutype=ANY_HDU, extver=0): """ Move to the indicated HDU by name In general, it is not necessary to use this method explicitly. returns the one-offset extension number """ extname = mks(extname) hdu = self._FITS.movnam_hdu(hdutype,...
python
def movnam_hdu(self, extname, hdutype=ANY_HDU, extver=0): """ Move to the indicated HDU by name In general, it is not necessary to use this method explicitly. returns the one-offset extension number """ extname = mks(extname) hdu = self._FITS.movnam_hdu(hdutype,...
[ "def", "movnam_hdu", "(", "self", ",", "extname", ",", "hdutype", "=", "ANY_HDU", ",", "extver", "=", "0", ")", ":", "extname", "=", "mks", "(", "extname", ")", "hdu", "=", "self", ".", "_FITS", ".", "movnam_hdu", "(", "hdutype", ",", "extname", ",",...
Move to the indicated HDU by name In general, it is not necessary to use this method explicitly. returns the one-offset extension number
[ "Move", "to", "the", "indicated", "HDU", "by", "name" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L452-L462
esheldon/fitsio
fitsio/fitslib.py
FITS.reopen
def reopen(self): """ close and reopen the fits file with the same mode """ self._FITS.close() del self._FITS self._FITS = _fitsio_wrap.FITS(self._filename, self.intmode, 0) self.update_hdu_list()
python
def reopen(self): """ close and reopen the fits file with the same mode """ self._FITS.close() del self._FITS self._FITS = _fitsio_wrap.FITS(self._filename, self.intmode, 0) self.update_hdu_list()
[ "def", "reopen", "(", "self", ")", ":", "self", ".", "_FITS", ".", "close", "(", ")", "del", "self", ".", "_FITS", "self", ".", "_FITS", "=", "_fitsio_wrap", ".", "FITS", "(", "self", ".", "_filename", ",", "self", ".", "intmode", ",", "0", ")", ...
close and reopen the fits file with the same mode
[ "close", "and", "reopen", "the", "fits", "file", "with", "the", "same", "mode" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L464-L471
esheldon/fitsio
fitsio/fitslib.py
FITS.write
def write(self, data, units=None, extname=None, extver=None, compress=None, tile_dims=None, header=None, names=None, table_type='binary', write_bitcols=False, **keys): """ Write the data to a new HDU. This method is a wrapper. If this is ...
python
def write(self, data, units=None, extname=None, extver=None, compress=None, tile_dims=None, header=None, names=None, table_type='binary', write_bitcols=False, **keys): """ Write the data to a new HDU. This method is a wrapper. If this is ...
[ "def", "write", "(", "self", ",", "data", ",", "units", "=", "None", ",", "extname", "=", "None", ",", "extver", "=", "None", ",", "compress", "=", "None", ",", "tile_dims", "=", "None", ",", "header", "=", "None", ",", "names", "=", "None", ",", ...
Write the data to a new HDU. This method is a wrapper. If this is an IMAGE_HDU, write_image is called, otherwise write_table is called. parameters ---------- data: ndarray An n-dimensional image or an array with fields. extname: string, optional ...
[ "Write", "the", "data", "to", "a", "new", "HDU", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L473-L549
esheldon/fitsio
fitsio/fitslib.py
FITS.write_image
def write_image(self, img, extname=None, extver=None, compress=None, tile_dims=None, header=None): """ Create a new image extension and write the data. parameters ---------- img: ndarray An n-dimensional image. extname: string, optional ...
python
def write_image(self, img, extname=None, extver=None, compress=None, tile_dims=None, header=None): """ Create a new image extension and write the data. parameters ---------- img: ndarray An n-dimensional image. extname: string, optional ...
[ "def", "write_image", "(", "self", ",", "img", ",", "extname", "=", "None", ",", "extver", "=", "None", ",", "compress", "=", "None", ",", "tile_dims", "=", "None", ",", "header", "=", "None", ")", ":", "self", ".", "create_image_hdu", "(", "img", ",...
Create a new image extension and write the data. parameters ---------- img: ndarray An n-dimensional image. extname: string, optional An optional extension name. extver: integer, optional FITS allows multiple extensions to have the same name (...
[ "Create", "a", "new", "image", "extension", "and", "write", "the", "data", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L551-L601
esheldon/fitsio
fitsio/fitslib.py
FITS.create_image_hdu
def create_image_hdu(self, img=None, dims=None, dtype=None, extname=None, extver=None, compress=None, tile_dims=None, he...
python
def create_image_hdu(self, img=None, dims=None, dtype=None, extname=None, extver=None, compress=None, tile_dims=None, he...
[ "def", "create_image_hdu", "(", "self", ",", "img", "=", "None", ",", "dims", "=", "None", ",", "dtype", "=", "None", ",", "extname", "=", "None", ",", "extver", "=", "None", ",", "compress", "=", "None", ",", "tile_dims", "=", "None", ",", "header",...
Create a new, empty image HDU and reload the hdu list. Either create from an input image or from input dims and dtype fits.create_image_hdu(image, ...) fits.create_image_hdu(dims=dims, dtype=dtype) If an image is sent, the data are also written. You can write data int...
[ "Create", "a", "new", "empty", "image", "HDU", "and", "reload", "the", "hdu", "list", ".", "Either", "create", "from", "an", "input", "image", "or", "from", "input", "dims", "and", "dtype" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L606-L765
esheldon/fitsio
fitsio/fitslib.py
FITS._ensure_empty_image_ok
def _ensure_empty_image_ok(self): """ If ignore_empty was not set to True, we only allow empty HDU for first HDU and if there is no data there already """ if self.ignore_empty: return if len(self) > 1: raise RuntimeError( "Cannot w...
python
def _ensure_empty_image_ok(self): """ If ignore_empty was not set to True, we only allow empty HDU for first HDU and if there is no data there already """ if self.ignore_empty: return if len(self) > 1: raise RuntimeError( "Cannot w...
[ "def", "_ensure_empty_image_ok", "(", "self", ")", ":", "if", "self", ".", "ignore_empty", ":", "return", "if", "len", "(", "self", ")", ">", "1", ":", "raise", "RuntimeError", "(", "\"Cannot write None image at extension %d\"", "%", "len", "(", "self", ")", ...
If ignore_empty was not set to True, we only allow empty HDU for first HDU and if there is no data there already
[ "If", "ignore_empty", "was", "not", "set", "to", "True", "we", "only", "allow", "empty", "HDU", "for", "first", "HDU", "and", "if", "there", "is", "no", "data", "there", "already" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L767-L780
esheldon/fitsio
fitsio/fitslib.py
FITS.write_table
def write_table(self, data, table_type='binary', names=None, formats=None, units=None, extname=None, extver=None, header=None, write_bitcols=False): """ Create a new table extension and write the data. The table definition is taken fro...
python
def write_table(self, data, table_type='binary', names=None, formats=None, units=None, extname=None, extver=None, header=None, write_bitcols=False): """ Create a new table extension and write the data. The table definition is taken fro...
[ "def", "write_table", "(", "self", ",", "data", ",", "table_type", "=", "'binary'", ",", "names", "=", "None", ",", "formats", "=", "None", ",", "units", "=", "None", ",", "extname", "=", "None", ",", "extver", "=", "None", ",", "header", "=", "None"...
Create a new table extension and write the data. The table definition is taken from the fields in the input array. If you want to append new rows to the table, access the HDU directly and use the write() function, e.g. fits[extension].append(data) parameters -----...
[ "Create", "a", "new", "table", "extension", "and", "write", "the", "data", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L782-L853
esheldon/fitsio
fitsio/fitslib.py
FITS.create_table_hdu
def create_table_hdu(self, data=None, dtype=None, header=None, names=None, formats=None, units=None, dims=None, extname=None, extver=None, table_type='binary', write_bitcols=False): """ Create a new, empt...
python
def create_table_hdu(self, data=None, dtype=None, header=None, names=None, formats=None, units=None, dims=None, extname=None, extver=None, table_type='binary', write_bitcols=False): """ Create a new, empt...
[ "def", "create_table_hdu", "(", "self", ",", "data", "=", "None", ",", "dtype", "=", "None", ",", "header", "=", "None", ",", "names", "=", "None", ",", "formats", "=", "None", ",", "units", "=", "None", ",", "dims", "=", "None", ",", "extname", "=...
Create a new, empty table extension and reload the hdu list. There are three ways to do it: 1) send a numpy dtype, from which the formats in the fits file will be determined. 2) Send an array in data= keyword. this is required if you have object fields fo...
[ "Create", "a", "new", "empty", "table", "extension", "and", "reload", "the", "hdu", "list", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L861-L1017
esheldon/fitsio
fitsio/fitslib.py
FITS.update_hdu_list
def update_hdu_list(self, rebuild=True): """ Force an update of the entire HDU list Normally you don't need to call this method directly if rebuild is false or the hdu_list is not yet set, the list is rebuilt from scratch """ if not hasattr(self, 'hdu_list'): ...
python
def update_hdu_list(self, rebuild=True): """ Force an update of the entire HDU list Normally you don't need to call this method directly if rebuild is false or the hdu_list is not yet set, the list is rebuilt from scratch """ if not hasattr(self, 'hdu_list'): ...
[ "def", "update_hdu_list", "(", "self", ",", "rebuild", "=", "True", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'hdu_list'", ")", ":", "rebuild", "=", "True", "if", "rebuild", ":", "self", ".", "hdu_list", "=", "[", "]", "self", ".", "hdu_ma...
Force an update of the entire HDU list Normally you don't need to call this method directly if rebuild is false or the hdu_list is not yet set, the list is rebuilt from scratch
[ "Force", "an", "update", "of", "the", "entire", "HDU", "list" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1019-L1051
esheldon/fitsio
fitsio/fitslib.py
FITS._append_hdu_info
def _append_hdu_info(self, ext): """ internal routine append info for indiciated extension """ # raised IOError if not found hdu_type = self._FITS.movabs_hdu(ext+1) if hdu_type == IMAGE_HDU: hdu = ImageHDU(self._FITS, ext, **self.keys) elif ...
python
def _append_hdu_info(self, ext): """ internal routine append info for indiciated extension """ # raised IOError if not found hdu_type = self._FITS.movabs_hdu(ext+1) if hdu_type == IMAGE_HDU: hdu = ImageHDU(self._FITS, ext, **self.keys) elif ...
[ "def", "_append_hdu_info", "(", "self", ",", "ext", ")", ":", "# raised IOError if not found", "hdu_type", "=", "self", ".", "_FITS", ".", "movabs_hdu", "(", "ext", "+", "1", ")", "if", "hdu_type", "==", "IMAGE_HDU", ":", "hdu", "=", "ImageHDU", "(", "self...
internal routine append info for indiciated extension
[ "internal", "routine" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1053-L1090
esheldon/fitsio
fitsio/fitslib.py
FITS.next
def next(self): """ Move to the next iteration """ if self._iter_index == len(self.hdu_list): raise StopIteration hdu = self.hdu_list[self._iter_index] self._iter_index += 1 return hdu
python
def next(self): """ Move to the next iteration """ if self._iter_index == len(self.hdu_list): raise StopIteration hdu = self.hdu_list[self._iter_index] self._iter_index += 1 return hdu
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "_iter_index", "==", "len", "(", "self", ".", "hdu_list", ")", ":", "raise", "StopIteration", "hdu", "=", "self", ".", "hdu_list", "[", "self", ".", "_iter_index", "]", "self", ".", "_iter_index"...
Move to the next iteration
[ "Move", "to", "the", "next", "iteration" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1101-L1109
esheldon/fitsio
fitsio/fitslib.py
FITS._extract_item
def _extract_item(self, item): """ utility function to extract an "item", meaning a extension number,name plus version. """ ver = 0 if isinstance(item, tuple): ver_sent = True nitem = len(item) if nitem == 1: ext = item[...
python
def _extract_item(self, item): """ utility function to extract an "item", meaning a extension number,name plus version. """ ver = 0 if isinstance(item, tuple): ver_sent = True nitem = len(item) if nitem == 1: ext = item[...
[ "def", "_extract_item", "(", "self", ",", "item", ")", ":", "ver", "=", "0", "if", "isinstance", "(", "item", ",", "tuple", ")", ":", "ver_sent", "=", "True", "nitem", "=", "len", "(", "item", ")", "if", "nitem", "==", "1", ":", "ext", "=", "item...
utility function to extract an "item", meaning a extension number,name plus version.
[ "utility", "function", "to", "extract", "an", "item", "meaning", "a", "extension", "number", "name", "plus", "version", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/fitslib.py#L1121-L1137
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU._update_info
def _update_info(self): """ Call parent method and make sure this is in fact a image HDU. Set dims in C order """ super(ImageHDU, self)._update_info() if self._info['hdutype'] != IMAGE_HDU: mess = "Extension %s is not a Image HDU" % self.ext rais...
python
def _update_info(self): """ Call parent method and make sure this is in fact a image HDU. Set dims in C order """ super(ImageHDU, self)._update_info() if self._info['hdutype'] != IMAGE_HDU: mess = "Extension %s is not a Image HDU" % self.ext rais...
[ "def", "_update_info", "(", "self", ")", ":", "super", "(", "ImageHDU", ",", "self", ")", ".", "_update_info", "(", ")", "if", "self", ".", "_info", "[", "'hdutype'", "]", "!=", "IMAGE_HDU", ":", "mess", "=", "\"Extension %s is not a Image HDU\"", "%", "se...
Call parent method and make sure this is in fact a image HDU. Set dims in C order
[ "Call", "parent", "method", "and", "make", "sure", "this", "is", "in", "fact", "a", "image", "HDU", ".", "Set", "dims", "in", "C", "order" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L37-L50
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU.reshape
def reshape(self, dims): """ reshape an existing image to the requested dimensions parameters ---------- dims: sequence Any sequence convertible to i8 """ adims = numpy.array(dims, ndmin=1, dtype='i8') self._FITS.reshape_image(self._ext+1, ad...
python
def reshape(self, dims): """ reshape an existing image to the requested dimensions parameters ---------- dims: sequence Any sequence convertible to i8 """ adims = numpy.array(dims, ndmin=1, dtype='i8') self._FITS.reshape_image(self._ext+1, ad...
[ "def", "reshape", "(", "self", ",", "dims", ")", ":", "adims", "=", "numpy", ".", "array", "(", "dims", ",", "ndmin", "=", "1", ",", "dtype", "=", "'i8'", ")", "self", ".", "_FITS", ".", "reshape_image", "(", "self", ".", "_ext", "+", "1", ",", ...
reshape an existing image to the requested dimensions parameters ---------- dims: sequence Any sequence convertible to i8
[ "reshape", "an", "existing", "image", "to", "the", "requested", "dimensions" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L91-L102
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU.write
def write(self, img, start=0, **keys): """ Write the image into this HDU If data already exist in this HDU, they will be overwritten. If the image to write is larger than the image on disk, or if the start position is such that the write would extend beyond the existing ...
python
def write(self, img, start=0, **keys): """ Write the image into this HDU If data already exist in this HDU, they will be overwritten. If the image to write is larger than the image on disk, or if the start position is such that the write would extend beyond the existing ...
[ "def", "write", "(", "self", ",", "img", ",", "start", "=", "0", ",", "*", "*", "keys", ")", ":", "dims", "=", "self", ".", "get_dims", "(", ")", "if", "img", ".", "dtype", ".", "fields", "is", "not", "None", ":", "raise", "ValueError", "(", "\...
Write the image into this HDU If data already exist in this HDU, they will be overwritten. If the image to write is larger than the image on disk, or if the start position is such that the write would extend beyond the existing dimensions, the on-disk image is expanded. parame...
[ "Write", "the", "image", "into", "this", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L104-L156
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU.read
def read(self, **keys): """ Read the image. If the HDU is an IMAGE_HDU, read the corresponding image. Compression and scaling are dealt with properly. """ if not self.has_data(): return None dtype, shape = self._get_dtype_and_shape() array =...
python
def read(self, **keys): """ Read the image. If the HDU is an IMAGE_HDU, read the corresponding image. Compression and scaling are dealt with properly. """ if not self.has_data(): return None dtype, shape = self._get_dtype_and_shape() array =...
[ "def", "read", "(", "self", ",", "*", "*", "keys", ")", ":", "if", "not", "self", ".", "has_data", "(", ")", ":", "return", "None", "dtype", ",", "shape", "=", "self", ".", "_get_dtype_and_shape", "(", ")", "array", "=", "numpy", ".", "zeros", "(",...
Read the image. If the HDU is an IMAGE_HDU, read the corresponding image. Compression and scaling are dealt with properly.
[ "Read", "the", "image", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L158-L171
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU._get_dtype_and_shape
def _get_dtype_and_shape(self): """ Get the numpy dtype and shape for image """ npy_dtype = self._get_image_numpy_dtype() if self._info['ndims'] != 0: shape = self._info['dims'] else: raise IOError("no image present in HDU") return npy_dt...
python
def _get_dtype_and_shape(self): """ Get the numpy dtype and shape for image """ npy_dtype = self._get_image_numpy_dtype() if self._info['ndims'] != 0: shape = self._info['dims'] else: raise IOError("no image present in HDU") return npy_dt...
[ "def", "_get_dtype_and_shape", "(", "self", ")", ":", "npy_dtype", "=", "self", ".", "_get_image_numpy_dtype", "(", ")", "if", "self", ".", "_info", "[", "'ndims'", "]", "!=", "0", ":", "shape", "=", "self", ".", "_info", "[", "'dims'", "]", "else", ":...
Get the numpy dtype and shape for image
[ "Get", "the", "numpy", "dtype", "and", "shape", "for", "image" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L173-L184
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU._get_image_numpy_dtype
def _get_image_numpy_dtype(self): """ Get the numpy dtype for the image """ try: ftype = self._info['img_equiv_type'] npy_type = _image_bitpix2npy[ftype] except KeyError: raise KeyError("unsupported fits data type: %d" % ftype) return ...
python
def _get_image_numpy_dtype(self): """ Get the numpy dtype for the image """ try: ftype = self._info['img_equiv_type'] npy_type = _image_bitpix2npy[ftype] except KeyError: raise KeyError("unsupported fits data type: %d" % ftype) return ...
[ "def", "_get_image_numpy_dtype", "(", "self", ")", ":", "try", ":", "ftype", "=", "self", ".", "_info", "[", "'img_equiv_type'", "]", "npy_type", "=", "_image_bitpix2npy", "[", "ftype", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "\"unsupported f...
Get the numpy dtype for the image
[ "Get", "the", "numpy", "dtype", "for", "the", "image" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L186-L196
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU._read_image_slice
def _read_image_slice(self, arg): """ workhorse to read a slice """ if 'ndims' not in self._info: raise ValueError("Attempt to slice empty extension") if isinstance(arg, slice): # one-dimensional, e.g. 2:20 return self._read_image_slice((arg,)...
python
def _read_image_slice(self, arg): """ workhorse to read a slice """ if 'ndims' not in self._info: raise ValueError("Attempt to slice empty extension") if isinstance(arg, slice): # one-dimensional, e.g. 2:20 return self._read_image_slice((arg,)...
[ "def", "_read_image_slice", "(", "self", ",", "arg", ")", ":", "if", "'ndims'", "not", "in", "self", ".", "_info", ":", "raise", "ValueError", "(", "\"Attempt to slice empty extension\"", ")", "if", "isinstance", "(", "arg", ",", "slice", ")", ":", "# one-di...
workhorse to read a slice
[ "workhorse", "to", "read", "a", "slice" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L206-L295
esheldon/fitsio
fitsio/hdu/image.py
ImageHDU._expand_if_needed
def _expand_if_needed(self, dims, write_dims, start, offset): """ expand the on-disk image if the indended write will extend beyond the existing dimensions """ from operator import mul if numpy.isscalar(start): start_is_scalar = True else: ...
python
def _expand_if_needed(self, dims, write_dims, start, offset): """ expand the on-disk image if the indended write will extend beyond the existing dimensions """ from operator import mul if numpy.isscalar(start): start_is_scalar = True else: ...
[ "def", "_expand_if_needed", "(", "self", ",", "dims", ",", "write_dims", ",", "start", ",", "offset", ")", ":", "from", "operator", "import", "mul", "if", "numpy", ".", "isscalar", "(", "start", ")", ":", "start_is_scalar", "=", "True", "else", ":", "sta...
expand the on-disk image if the indended write will extend beyond the existing dimensions
[ "expand", "the", "on", "-", "disk", "image", "if", "the", "indended", "write", "will", "extend", "beyond", "the", "existing", "dimensions" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/image.py#L297-L350
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.get_extname
def get_extname(self): """ Get the name for this extension, can be an empty string """ name = self._info['extname'] if name.strip() == '': name = self._info['hduname'] return name.strip()
python
def get_extname(self): """ Get the name for this extension, can be an empty string """ name = self._info['extname'] if name.strip() == '': name = self._info['hduname'] return name.strip()
[ "def", "get_extname", "(", "self", ")", ":", "name", "=", "self", ".", "_info", "[", "'extname'", "]", "if", "name", ".", "strip", "(", ")", "==", "''", ":", "name", "=", "self", ".", "_info", "[", "'hduname'", "]", "return", "name", ".", "strip", ...
Get the name for this extension, can be an empty string
[ "Get", "the", "name", "for", "this", "extension", "can", "be", "an", "empty", "string" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L59-L66
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.get_extver
def get_extver(self): """ Get the version for this extension. Used when a name is given to multiple extensions """ ver = self._info['extver'] if ver == 0: ver = self._info['hduver'] return ver
python
def get_extver(self): """ Get the version for this extension. Used when a name is given to multiple extensions """ ver = self._info['extver'] if ver == 0: ver = self._info['hduver'] return ver
[ "def", "get_extver", "(", "self", ")", ":", "ver", "=", "self", ".", "_info", "[", "'extver'", "]", "if", "ver", "==", "0", ":", "ver", "=", "self", ".", "_info", "[", "'hduver'", "]", "return", "ver" ]
Get the version for this extension. Used when a name is given to multiple extensions
[ "Get", "the", "version", "for", "this", "extension", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L68-L77
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.get_exttype
def get_exttype(self, num=False): """ Get the extension type By default the result is a string that mirrors the enumerated type names in cfitsio 'IMAGE_HDU', 'ASCII_TBL', 'BINARY_TBL' which have numeric values 0 1 2 send num=True to get the number...
python
def get_exttype(self, num=False): """ Get the extension type By default the result is a string that mirrors the enumerated type names in cfitsio 'IMAGE_HDU', 'ASCII_TBL', 'BINARY_TBL' which have numeric values 0 1 2 send num=True to get the number...
[ "def", "get_exttype", "(", "self", ",", "num", "=", "False", ")", ":", "if", "num", ":", "return", "self", ".", "_info", "[", "'hdutype'", "]", "else", ":", "name", "=", "_hdu_type_map", "[", "self", ".", "_info", "[", "'hdutype'", "]", "]", "return"...
Get the extension type By default the result is a string that mirrors the enumerated type names in cfitsio 'IMAGE_HDU', 'ASCII_TBL', 'BINARY_TBL' which have numeric values 0 1 2 send num=True to get the numbers. The values fitsio.IMAGE_HDU .ASCII_TBL...
[ "Get", "the", "extension", "type" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L79-L101
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.get_offsets
def get_offsets(self): """ returns ------- a dictionary with these entries header_start: byte offset from beginning of the file to the start of the header data_start: byte offset from beginning of the file to the start of t...
python
def get_offsets(self): """ returns ------- a dictionary with these entries header_start: byte offset from beginning of the file to the start of the header data_start: byte offset from beginning of the file to the start of t...
[ "def", "get_offsets", "(", "self", ")", ":", "return", "dict", "(", "header_start", "=", "self", ".", "_info", "[", "'header_start'", "]", ",", "data_start", "=", "self", ".", "_info", "[", "'data_start'", "]", ",", "data_end", "=", "self", ".", "_info",...
returns ------- a dictionary with these entries header_start: byte offset from beginning of the file to the start of the header data_start: byte offset from beginning of the file to the start of the data section data_end: ...
[ "returns", "-------", "a", "dictionary", "with", "these", "entries" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L103-L126
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.verify_checksum
def verify_checksum(self): """ Verify the checksum in the header for this HDU. """ res = self._FITS.verify_checksum(self._ext+1) if res['dataok'] != 1: raise ValueError("data checksum failed") if res['hduok'] != 1: raise ValueError("hdu checksum fa...
python
def verify_checksum(self): """ Verify the checksum in the header for this HDU. """ res = self._FITS.verify_checksum(self._ext+1) if res['dataok'] != 1: raise ValueError("data checksum failed") if res['hduok'] != 1: raise ValueError("hdu checksum fa...
[ "def", "verify_checksum", "(", "self", ")", ":", "res", "=", "self", ".", "_FITS", ".", "verify_checksum", "(", "self", ".", "_ext", "+", "1", ")", "if", "res", "[", "'dataok'", "]", "!=", "1", ":", "raise", "ValueError", "(", "\"data checksum failed\"",...
Verify the checksum in the header for this HDU.
[ "Verify", "the", "checksum", "in", "the", "header", "for", "this", "HDU", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L153-L161
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.write_comment
def write_comment(self, comment): """ Write a comment into the header """ self._FITS.write_comment(self._ext+1, str(comment))
python
def write_comment(self, comment): """ Write a comment into the header """ self._FITS.write_comment(self._ext+1, str(comment))
[ "def", "write_comment", "(", "self", ",", "comment", ")", ":", "self", ".", "_FITS", ".", "write_comment", "(", "self", ".", "_ext", "+", "1", ",", "str", "(", "comment", ")", ")" ]
Write a comment into the header
[ "Write", "a", "comment", "into", "the", "header" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L163-L167
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.write_history
def write_history(self, history): """ Write history text into the header """ self._FITS.write_history(self._ext+1, str(history))
python
def write_history(self, history): """ Write history text into the header """ self._FITS.write_history(self._ext+1, str(history))
[ "def", "write_history", "(", "self", ",", "history", ")", ":", "self", ".", "_FITS", ".", "write_history", "(", "self", ".", "_ext", "+", "1", ",", "str", "(", "history", ")", ")" ]
Write history text into the header
[ "Write", "history", "text", "into", "the", "header" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L169-L173
esheldon/fitsio
fitsio/hdu/base.py
HDUBase._write_continue
def _write_continue(self, value): """ Write history text into the header """ self._FITS.write_continue(self._ext+1, str(value))
python
def _write_continue(self, value): """ Write history text into the header """ self._FITS.write_continue(self._ext+1, str(value))
[ "def", "_write_continue", "(", "self", ",", "value", ")", ":", "self", ".", "_FITS", ".", "write_continue", "(", "self", ".", "_ext", "+", "1", ",", "str", "(", "value", ")", ")" ]
Write history text into the header
[ "Write", "history", "text", "into", "the", "header" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L175-L179
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.write_key
def write_key(self, name, value, comment=""): """ Write the input value to the header parameters ---------- name: string Name of keyword to write/update value: scalar Value to write, can be string float or integer type, including numpy...
python
def write_key(self, name, value, comment=""): """ Write the input value to the header parameters ---------- name: string Name of keyword to write/update value: scalar Value to write, can be string float or integer type, including numpy...
[ "def", "write_key", "(", "self", ",", "name", ",", "value", ",", "comment", "=", "\"\"", ")", ":", "if", "value", "is", "None", ":", "self", ".", "_FITS", ".", "write_undefined_key", "(", "self", ".", "_ext", "+", "1", ",", "str", "(", "name", ")",...
Write the input value to the header parameters ---------- name: string Name of keyword to write/update value: scalar Value to write, can be string float or integer type, including numpy scalar types. comment: string, optional An op...
[ "Write", "the", "input", "value", "to", "the", "header" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L181-L247
esheldon/fitsio
fitsio/hdu/base.py
HDUBase.write_keys
def write_keys(self, records_in, clean=True): """ Write the keywords to the header. parameters ---------- records: FITSHDR or list or dict Can be one of these: - FITSHDR object - list of dictionaries containing 'name','value' and optio...
python
def write_keys(self, records_in, clean=True): """ Write the keywords to the header. parameters ---------- records: FITSHDR or list or dict Can be one of these: - FITSHDR object - list of dictionaries containing 'name','value' and optio...
[ "def", "write_keys", "(", "self", ",", "records_in", ",", "clean", "=", "True", ")", ":", "if", "isinstance", "(", "records_in", ",", "FITSHDR", ")", ":", "hdr", "=", "records_in", "else", ":", "hdr", "=", "FITSHDR", "(", "records_in", ")", "if", "clea...
Write the keywords to the header. parameters ---------- records: FITSHDR or list or dict Can be one of these: - FITSHDR object - list of dictionaries containing 'name','value' and optionally a 'comment' field; the order is preserved....
[ "Write", "the", "keywords", "to", "the", "header", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L249-L295
esheldon/fitsio
fitsio/hdu/base.py
HDUBase._update_info
def _update_info(self): """ Update metadata for this HDU """ try: self._FITS.movabs_hdu(self._ext+1) except IOError: raise RuntimeError("no such hdu") self._info = self._FITS.get_hdu_info(self._ext+1)
python
def _update_info(self): """ Update metadata for this HDU """ try: self._FITS.movabs_hdu(self._ext+1) except IOError: raise RuntimeError("no such hdu") self._info = self._FITS.get_hdu_info(self._ext+1)
[ "def", "_update_info", "(", "self", ")", ":", "try", ":", "self", ".", "_FITS", ".", "movabs_hdu", "(", "self", ".", "_ext", "+", "1", ")", "except", "IOError", ":", "raise", "RuntimeError", "(", "\"no such hdu\"", ")", "self", ".", "_info", "=", "self...
Update metadata for this HDU
[ "Update", "metadata", "for", "this", "HDU" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L322-L331
esheldon/fitsio
fitsio/hdu/base.py
HDUBase._get_repr_list
def _get_repr_list(self): """ Get some representation data common to all HDU types """ spacing = ' '*2 text = [''] text.append("%sfile: %s" % (spacing, self._filename)) text.append("%sextension: %d" % (spacing, self._info['hdunum']-1)) text.append( ...
python
def _get_repr_list(self): """ Get some representation data common to all HDU types """ spacing = ' '*2 text = [''] text.append("%sfile: %s" % (spacing, self._filename)) text.append("%sextension: %d" % (spacing, self._info['hdunum']-1)) text.append( ...
[ "def", "_get_repr_list", "(", "self", ")", ":", "spacing", "=", "' '", "*", "2", "text", "=", "[", "''", "]", "text", ".", "append", "(", "\"%sfile: %s\"", "%", "(", "spacing", ",", "self", ".", "_filename", ")", ")", "text", ".", "append", "(", "\...
Get some representation data common to all HDU types
[ "Get", "some", "representation", "data", "common", "to", "all", "HDU", "types" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/hdu/base.py#L333-L351
esheldon/fitsio
fitsio/header.py
FITSHDR.add_record
def add_record(self, record_in): """ Add a new record. Strip quotes from around strings. This will over-write if the key already exists, except for COMMENT and HISTORY fields parameters ----------- record: The record, either a dict or a header card ...
python
def add_record(self, record_in): """ Add a new record. Strip quotes from around strings. This will over-write if the key already exists, except for COMMENT and HISTORY fields parameters ----------- record: The record, either a dict or a header card ...
[ "def", "add_record", "(", "self", ",", "record_in", ")", ":", "if", "(", "isinstance", "(", "record_in", ",", "dict", ")", "and", "'name'", "in", "record_in", "and", "'value'", "in", "record_in", ")", ":", "record", "=", "{", "}", "record", ".", "updat...
Add a new record. Strip quotes from around strings. This will over-write if the key already exists, except for COMMENT and HISTORY fields parameters ----------- record: The record, either a dict or a header card string or a FITSRecord or FITSCard ...
[ "Add", "a", "new", "record", ".", "Strip", "quotes", "from", "around", "strings", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L133-L174
esheldon/fitsio
fitsio/header.py
FITSHDR.get_comment
def get_comment(self, item): """ Get the comment for the requested entry """ key = item.upper() if key not in self._record_map: raise KeyError("unknown record: %s" % key) if 'comment' not in self._record_map[key]: return None else: ...
python
def get_comment(self, item): """ Get the comment for the requested entry """ key = item.upper() if key not in self._record_map: raise KeyError("unknown record: %s" % key) if 'comment' not in self._record_map[key]: return None else: ...
[ "def", "get_comment", "(", "self", ",", "item", ")", ":", "key", "=", "item", ".", "upper", "(", ")", "if", "key", "not", "in", "self", ".", "_record_map", ":", "raise", "KeyError", "(", "\"unknown record: %s\"", "%", "key", ")", "if", "'comment'", "no...
Get the comment for the requested entry
[ "Get", "the", "comment", "for", "the", "requested", "entry" ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L180-L191
esheldon/fitsio
fitsio/header.py
FITSHDR.delete
def delete(self, name): """ Delete the specified entry if it exists. """ if isinstance(name, (list, tuple)): for xx in name: self.delete(xx) else: if name in self._record_map: del self._record_map[name] self....
python
def delete(self, name): """ Delete the specified entry if it exists. """ if isinstance(name, (list, tuple)): for xx in name: self.delete(xx) else: if name in self._record_map: del self._record_map[name] self....
[ "def", "delete", "(", "self", ",", "name", ")", ":", "if", "isinstance", "(", "name", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "xx", "in", "name", ":", "self", ".", "delete", "(", "xx", ")", "else", ":", "if", "name", "in", "self",...
Delete the specified entry if it exists.
[ "Delete", "the", "specified", "entry", "if", "it", "exists", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L205-L216
esheldon/fitsio
fitsio/header.py
FITSHDR.clean
def clean(self, is_table=False): """ Remove reserved keywords from the header. These are keywords that the fits writer must write in order to maintain consistency between header and data. keywords -------- is_table: bool, optional Set True if this is...
python
def clean(self, is_table=False): """ Remove reserved keywords from the header. These are keywords that the fits writer must write in order to maintain consistency between header and data. keywords -------- is_table: bool, optional Set True if this is...
[ "def", "clean", "(", "self", ",", "is_table", "=", "False", ")", ":", "rmnames", "=", "[", "'SIMPLE'", ",", "'EXTEND'", ",", "'XTENSION'", ",", "'BITPIX'", ",", "'PCOUNT'", ",", "'GCOUNT'", ",", "'THEAP'", ",", "'EXTNAME'", ",", "'BLANK'", ",", "'ZQUANTI...
Remove reserved keywords from the header. These are keywords that the fits writer must write in order to maintain consistency between header and data. keywords -------- is_table: bool, optional Set True if this is a table, so extra keywords will be cleaned
[ "Remove", "reserved", "keywords", "from", "the", "header", "." ]
train
https://github.com/esheldon/fitsio/blob/a6f07919f457a282fe240adad9d2c30906b71a15/fitsio/header.py#L218-L288