partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | GuppiRaw.read_next_data_block_int8 | Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64. | blimpy/guppi.py | def read_next_data_block_int8(self):
""" Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64.
"""
header, data_idx = self.read_header()
... | def read_next_data_block_int8(self):
""" Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64.
"""
header, data_idx = self.read_header()
... | [
"Read",
"the",
"next",
"block",
"of",
"data",
"and",
"its",
"header"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L208-L239 | [
"def",
"read_next_data_block_int8",
"(",
"self",
")",
":",
"header",
",",
"data_idx",
"=",
"self",
".",
"read_header",
"(",
")",
"self",
".",
"file_obj",
".",
"seek",
"(",
"data_idx",
")",
"# Read data and reshape",
"n_chan",
"=",
"int",
"(",
"header",
"[",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | GuppiRaw.read_next_data_block_int8_2x | Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64. | blimpy/guppi.py | def read_next_data_block_int8_2x(self):
""" Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64.
"""
header, data_idx = self.read_header(... | def read_next_data_block_int8_2x(self):
""" Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64.
"""
header, data_idx = self.read_header(... | [
"Read",
"the",
"next",
"block",
"of",
"data",
"and",
"its",
"header"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L241-L279 | [
"def",
"read_next_data_block_int8_2x",
"(",
"self",
")",
":",
"header",
",",
"data_idx",
"=",
"self",
".",
"read_header",
"(",
")",
"self",
".",
"file_obj",
".",
"seek",
"(",
"data_idx",
")",
"# Read data and reshape",
"n_chan",
"=",
"int",
"(",
"header",
"[... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | GuppiRaw.read_next_data_block | Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64. | blimpy/guppi.py | def read_next_data_block(self):
""" Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64.
"""
header, data_idx = self.read_header()
... | def read_next_data_block(self):
""" Read the next block of data and its header
Returns: (header, data)
header (dict): dictionary of header metadata
data (np.array): Numpy array of data, converted into to complex64.
"""
header, data_idx = self.read_header()
... | [
"Read",
"the",
"next",
"block",
"of",
"data",
"and",
"its",
"header"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L281-L313 | [
"def",
"read_next_data_block",
"(",
"self",
")",
":",
"header",
",",
"data_idx",
"=",
"self",
".",
"read_header",
"(",
")",
"self",
".",
"file_obj",
".",
"seek",
"(",
"data_idx",
")",
"# Read data and reshape",
"n_chan",
"=",
"int",
"(",
"header",
"[",
"'O... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | GuppiRaw.find_n_data_blocks | Seek through the file to find how many data blocks there are in the file
Returns:
n_blocks (int): number of data blocks in the file | blimpy/guppi.py | def find_n_data_blocks(self):
""" Seek through the file to find how many data blocks there are in the file
Returns:
n_blocks (int): number of data blocks in the file
"""
self.file_obj.seek(0)
header0, data_idx0 = self.read_header()
self.file_obj.seek(data_id... | def find_n_data_blocks(self):
""" Seek through the file to find how many data blocks there are in the file
Returns:
n_blocks (int): number of data blocks in the file
"""
self.file_obj.seek(0)
header0, data_idx0 = self.read_header()
self.file_obj.seek(data_id... | [
"Seek",
"through",
"the",
"file",
"to",
"find",
"how",
"many",
"data",
"blocks",
"there",
"are",
"in",
"the",
"file"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L315-L341 | [
"def",
"find_n_data_blocks",
"(",
"self",
")",
":",
"self",
".",
"file_obj",
".",
"seek",
"(",
"0",
")",
"header0",
",",
"data_idx0",
"=",
"self",
".",
"read_header",
"(",
")",
"self",
".",
"file_obj",
".",
"seek",
"(",
"data_idx0",
")",
"block_size",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | GuppiRaw.print_stats | Compute some basic stats on the next block of data | blimpy/guppi.py | def print_stats(self):
""" Compute some basic stats on the next block of data """
header, data = self.read_next_data_block()
data = data.view('float32')
print("AVG: %2.3f" % data.mean())
print("STD: %2.3f" % data.std())
print("MAX: %2.3f" % data.max())
print("MI... | def print_stats(self):
""" Compute some basic stats on the next block of data """
header, data = self.read_next_data_block()
data = data.view('float32')
print("AVG: %2.3f" % data.mean())
print("STD: %2.3f" % data.std())
print("MAX: %2.3f" % data.max())
print("MI... | [
"Compute",
"some",
"basic",
"stats",
"on",
"the",
"next",
"block",
"of",
"data"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L347-L358 | [
"def",
"print_stats",
"(",
"self",
")",
":",
"header",
",",
"data",
"=",
"self",
".",
"read_next_data_block",
"(",
")",
"data",
"=",
"data",
".",
"view",
"(",
"'float32'",
")",
"print",
"(",
"\"AVG: %2.3f\"",
"%",
"data",
".",
"mean",
"(",
")",
")",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | GuppiRaw.plot_histogram | Plot a histogram of data values | blimpy/guppi.py | def plot_histogram(self, filename=None):
""" Plot a histogram of data values """
header, data = self.read_next_data_block()
data = data.view('float32')
plt.figure("Histogram")
plt.hist(data.flatten(), 65, facecolor='#cc0000')
if filename:
plt.savefig(filename... | def plot_histogram(self, filename=None):
""" Plot a histogram of data values """
header, data = self.read_next_data_block()
data = data.view('float32')
plt.figure("Histogram")
plt.hist(data.flatten(), 65, facecolor='#cc0000')
if filename:
plt.savefig(filename... | [
"Plot",
"a",
"histogram",
"of",
"data",
"values"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L360-L369 | [
"def",
"plot_histogram",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"header",
",",
"data",
"=",
"self",
".",
"read_next_data_block",
"(",
")",
"data",
"=",
"data",
".",
"view",
"(",
"'float32'",
")",
"plt",
".",
"figure",
"(",
"\"Histogram\"",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | GuppiRaw.plot_spectrum | Do a (slow) numpy FFT and take power of data | blimpy/guppi.py | def plot_spectrum(self, filename=None, plot_db=True):
""" Do a (slow) numpy FFT and take power of data """
header, data = self.read_next_data_block()
print("Computing FFT...")
d_xx_fft = np.abs(np.fft.fft(data[..., 0]))
d_xx_fft = d_xx_fft.flatten()
# Rebin to max numbe... | def plot_spectrum(self, filename=None, plot_db=True):
""" Do a (slow) numpy FFT and take power of data """
header, data = self.read_next_data_block()
print("Computing FFT...")
d_xx_fft = np.abs(np.fft.fft(data[..., 0]))
d_xx_fft = d_xx_fft.flatten()
# Rebin to max numbe... | [
"Do",
"a",
"(",
"slow",
")",
"numpy",
"FFT",
"and",
"take",
"power",
"of",
"data"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L371-L397 | [
"def",
"plot_spectrum",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"plot_db",
"=",
"True",
")",
":",
"header",
",",
"data",
"=",
"self",
".",
"read_next_data_block",
"(",
")",
"print",
"(",
"\"Computing FFT...\"",
")",
"d_xx_fft",
"=",
"np",
".",
"a... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | GuppiRaw.generate_filterbank_header | Generate a blimpy header dictionary | blimpy/guppi.py | def generate_filterbank_header(self, nchans=1, ):
""" Generate a blimpy header dictionary """
gp_head = self.read_first_header()
fb_head = {}
telescope_str = gp_head.get("TELESCOP", "unknown")
if telescope_str in ('GBT', 'GREENBANK'):
fb_head["telescope_id"] = 6
... | def generate_filterbank_header(self, nchans=1, ):
""" Generate a blimpy header dictionary """
gp_head = self.read_first_header()
fb_head = {}
telescope_str = gp_head.get("TELESCOP", "unknown")
if telescope_str in ('GBT', 'GREENBANK'):
fb_head["telescope_id"] = 6
... | [
"Generate",
"a",
"blimpy",
"header",
"dictionary"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/guppi.py#L399-L439 | [
"def",
"generate_filterbank_header",
"(",
"self",
",",
"nchans",
"=",
"1",
",",
")",
":",
"gp_head",
"=",
"self",
".",
"read_first_header",
"(",
")",
"fb_head",
"=",
"{",
"}",
"telescope_str",
"=",
"gp_head",
".",
"get",
"(",
"\"TELESCOP\"",
",",
"\"unknow... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | find_header_size | Script to find the header size of a filterbank file | blimpy/match_fils.py | def find_header_size(filename):
''' Script to find the header size of a filterbank file'''
# open datafile
filfile=open(filename,'rb')
# go to the start of the file
filfile.seek(0)
#read some region larger than the header.
round1 = filfile.read(1000)
headersize = round1.find('HEADER_END... | def find_header_size(filename):
''' Script to find the header size of a filterbank file'''
# open datafile
filfile=open(filename,'rb')
# go to the start of the file
filfile.seek(0)
#read some region larger than the header.
round1 = filfile.read(1000)
headersize = round1.find('HEADER_END... | [
"Script",
"to",
"find",
"the",
"header",
"size",
"of",
"a",
"filterbank",
"file"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/match_fils.py#L33-L44 | [
"def",
"find_header_size",
"(",
"filename",
")",
":",
"# open datafile",
"filfile",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"# go to the start of the file",
"filfile",
".",
"seek",
"(",
"0",
")",
"#read some region larger than the header.",
"round1",
"=",
"f... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | cmd_tool | Command line tool to make a md5sum comparison of two .fil files. | blimpy/match_fils.py | def cmd_tool(args=None):
""" Command line tool to make a md5sum comparison of two .fil files. """
if 'bl' in local_host:
header_loc = '/usr/local/sigproc/bin/header' #Current location of header command in GBT.
else:
raise IOError('Script only able to run in BL systems.')
p = OptionPars... | def cmd_tool(args=None):
""" Command line tool to make a md5sum comparison of two .fil files. """
if 'bl' in local_host:
header_loc = '/usr/local/sigproc/bin/header' #Current location of header command in GBT.
else:
raise IOError('Script only able to run in BL systems.')
p = OptionPars... | [
"Command",
"line",
"tool",
"to",
"make",
"a",
"md5sum",
"comparison",
"of",
"two",
".",
"fil",
"files",
"."
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/match_fils.py#L46-L142 | [
"def",
"cmd_tool",
"(",
"args",
"=",
"None",
")",
":",
"if",
"'bl'",
"in",
"local_host",
":",
"header_loc",
"=",
"'/usr/local/sigproc/bin/header'",
"#Current location of header command in GBT.",
"else",
":",
"raise",
"IOError",
"(",
"'Script only able to run in BL systems... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | make_h5_file | Converts file to HDF5 (.h5) format. Default saves output in current dir. | blimpy/fil2h5.py | def make_h5_file(filename,out_dir='./', new_filename = None, max_load = None):
''' Converts file to HDF5 (.h5) format. Default saves output in current dir.
'''
fil_file = Waterfall(filename, max_load = max_load)
if not new_filename:
new_filename = out_dir+filename.replace('.fil','.h5').split('/... | def make_h5_file(filename,out_dir='./', new_filename = None, max_load = None):
''' Converts file to HDF5 (.h5) format. Default saves output in current dir.
'''
fil_file = Waterfall(filename, max_load = max_load)
if not new_filename:
new_filename = out_dir+filename.replace('.fil','.h5').split('/... | [
"Converts",
"file",
"to",
"HDF5",
"(",
".",
"h5",
")",
"format",
".",
"Default",
"saves",
"output",
"in",
"current",
"dir",
"."
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/fil2h5.py#L37-L48 | [
"def",
"make_h5_file",
"(",
"filename",
",",
"out_dir",
"=",
"'./'",
",",
"new_filename",
"=",
"None",
",",
"max_load",
"=",
"None",
")",
":",
"fil_file",
"=",
"Waterfall",
"(",
"filename",
",",
"max_load",
"=",
"max_load",
")",
"if",
"not",
"new_filename"... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | cmd_tool | Command line tool for converting guppi raw into HDF5 versions of guppi raw | blimpy/gup2hdf.py | def cmd_tool(args=None):
""" Command line tool for converting guppi raw into HDF5 versions of guppi raw """
from argparse import ArgumentParser
if not HAS_BITSHUFFLE:
print("Error: the bitshuffle library is required to run this script.")
exit()
parser = ArgumentParser(description="Comm... | def cmd_tool(args=None):
""" Command line tool for converting guppi raw into HDF5 versions of guppi raw """
from argparse import ArgumentParser
if not HAS_BITSHUFFLE:
print("Error: the bitshuffle library is required to run this script.")
exit()
parser = ArgumentParser(description="Comm... | [
"Command",
"line",
"tool",
"for",
"converting",
"guppi",
"raw",
"into",
"HDF5",
"versions",
"of",
"guppi",
"raw"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/gup2hdf.py#L16-L89 | [
"def",
"cmd_tool",
"(",
"args",
"=",
"None",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
"if",
"not",
"HAS_BITSHUFFLE",
":",
"print",
"(",
"\"Error: the bitshuffle library is required to run this script.\"",
")",
"exit",
"(",
")",
"parser",
"=",
"Argum... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | foldcal | Returns time-averaged spectra of the ON and OFF measurements in a
calibrator measurement with flickering noise diode
Parameters
----------
data : 2D Array object (float)
2D dynamic spectrum for data (any Stokes parameter) with flickering noise diode.
tsamp : float
Sampling time of d... | blimpy/calib_utils/fluxcal.py | def foldcal(data,tsamp, diode_p=0.04,numsamps=1000,switch=False,inds=False):
'''
Returns time-averaged spectra of the ON and OFF measurements in a
calibrator measurement with flickering noise diode
Parameters
----------
data : 2D Array object (float)
2D dynamic spectrum for data (any St... | def foldcal(data,tsamp, diode_p=0.04,numsamps=1000,switch=False,inds=False):
'''
Returns time-averaged spectra of the ON and OFF measurements in a
calibrator measurement with flickering noise diode
Parameters
----------
data : 2D Array object (float)
2D dynamic spectrum for data (any St... | [
"Returns",
"time",
"-",
"averaged",
"spectra",
"of",
"the",
"ON",
"and",
"OFF",
"measurements",
"in",
"a",
"calibrator",
"measurement",
"with",
"flickering",
"noise",
"diode"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L6-L66 | [
"def",
"foldcal",
"(",
"data",
",",
"tsamp",
",",
"diode_p",
"=",
"0.04",
",",
"numsamps",
"=",
"1000",
",",
"switch",
"=",
"False",
",",
"inds",
"=",
"False",
")",
":",
"halfper",
"=",
"diode_p",
"/",
"2.0",
"foldt",
"=",
"halfper",
"/",
"tsamp",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | integrate_chans | Integrates over each core channel of a given spectrum.
Important for calibrating data with frequency/time resolution different from noise diode data
Parameters
----------
spec : 1D Array (float)
Spectrum (any Stokes parameter) to be integrated
freqs : 1D Array (float)
Frequency valu... | blimpy/calib_utils/fluxcal.py | def integrate_chans(spec,freqs,chan_per_coarse):
'''
Integrates over each core channel of a given spectrum.
Important for calibrating data with frequency/time resolution different from noise diode data
Parameters
----------
spec : 1D Array (float)
Spectrum (any Stokes parameter) to be i... | def integrate_chans(spec,freqs,chan_per_coarse):
'''
Integrates over each core channel of a given spectrum.
Important for calibrating data with frequency/time resolution different from noise diode data
Parameters
----------
spec : 1D Array (float)
Spectrum (any Stokes parameter) to be i... | [
"Integrates",
"over",
"each",
"core",
"channel",
"of",
"a",
"given",
"spectrum",
".",
"Important",
"for",
"calibrating",
"data",
"with",
"frequency",
"/",
"time",
"resolution",
"different",
"from",
"noise",
"diode",
"data"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L68-L90 | [
"def",
"integrate_chans",
"(",
"spec",
",",
"freqs",
",",
"chan_per_coarse",
")",
":",
"num_coarse",
"=",
"spec",
".",
"size",
"/",
"chan_per_coarse",
"#Calculate total number of coarse channels",
"#Rearrange spectrum by coarse channel",
"spec_shaped",
"=",
"np",
".",
"... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | integrate_calib | Folds Stokes I noise diode data and integrates along coarse channels
Parameters
----------
name : str
Path to noise diode filterbank file
chan_per_coarse : int
Number of frequency bins per coarse channel
fullstokes : boolean
Use fullstokes=True if data is in IQUV format or j... | blimpy/calib_utils/fluxcal.py | def integrate_calib(name,chan_per_coarse,fullstokes=False,**kwargs):
'''
Folds Stokes I noise diode data and integrates along coarse channels
Parameters
----------
name : str
Path to noise diode filterbank file
chan_per_coarse : int
Number of frequency bins per coarse channel
... | def integrate_calib(name,chan_per_coarse,fullstokes=False,**kwargs):
'''
Folds Stokes I noise diode data and integrates along coarse channels
Parameters
----------
name : str
Path to noise diode filterbank file
chan_per_coarse : int
Number of frequency bins per coarse channel
... | [
"Folds",
"Stokes",
"I",
"noise",
"diode",
"data",
"and",
"integrates",
"along",
"coarse",
"channels"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L92-L137 | [
"def",
"integrate_calib",
"(",
"name",
",",
"chan_per_coarse",
",",
"fullstokes",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"#Load data",
"obs",
"=",
"Waterfall",
"(",
"name",
",",
"max_load",
"=",
"150",
")",
"data",
"=",
"obs",
".",
"data",
"#... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | get_calfluxes | Given properties of the calibrator source, calculate fluxes of the source
in a particular frequency range
Parameters
----------
calflux : float
Known flux of calibrator source at a particular frequency
calfreq : float
Frequency where calibrator source has flux calflux (see above)
... | blimpy/calib_utils/fluxcal.py | def get_calfluxes(calflux,calfreq,spec_in,centerfreqs,oneflux):
'''
Given properties of the calibrator source, calculate fluxes of the source
in a particular frequency range
Parameters
----------
calflux : float
Known flux of calibrator source at a particular frequency
calfreq : flo... | def get_calfluxes(calflux,calfreq,spec_in,centerfreqs,oneflux):
'''
Given properties of the calibrator source, calculate fluxes of the source
in a particular frequency range
Parameters
----------
calflux : float
Known flux of calibrator source at a particular frequency
calfreq : flo... | [
"Given",
"properties",
"of",
"the",
"calibrator",
"source",
"calculate",
"fluxes",
"of",
"the",
"source",
"in",
"a",
"particular",
"frequency",
"range"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L139-L163 | [
"def",
"get_calfluxes",
"(",
"calflux",
",",
"calfreq",
",",
"spec_in",
",",
"centerfreqs",
",",
"oneflux",
")",
":",
"const",
"=",
"calflux",
"/",
"np",
".",
"power",
"(",
"calfreq",
",",
"spec_in",
")",
"if",
"oneflux",
"==",
"False",
":",
"return",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | get_centerfreqs | Returns central frequency of each coarse channel
Parameters
----------
freqs : 1D Array (float)
Frequency values for each bin of the spectrum
chan_per_coarse: int
Number of frequency bins per coarse channel | blimpy/calib_utils/fluxcal.py | def get_centerfreqs(freqs,chan_per_coarse):
'''
Returns central frequency of each coarse channel
Parameters
----------
freqs : 1D Array (float)
Frequency values for each bin of the spectrum
chan_per_coarse: int
Number of frequency bins per coarse channel
'''
num_coarse ... | def get_centerfreqs(freqs,chan_per_coarse):
'''
Returns central frequency of each coarse channel
Parameters
----------
freqs : 1D Array (float)
Frequency values for each bin of the spectrum
chan_per_coarse: int
Number of frequency bins per coarse channel
'''
num_coarse ... | [
"Returns",
"central",
"frequency",
"of",
"each",
"coarse",
"channel"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L165-L179 | [
"def",
"get_centerfreqs",
"(",
"freqs",
",",
"chan_per_coarse",
")",
":",
"num_coarse",
"=",
"freqs",
".",
"size",
"/",
"chan_per_coarse",
"freqs",
"=",
"np",
".",
"reshape",
"(",
"freqs",
",",
"(",
"num_coarse",
",",
"chan_per_coarse",
")",
")",
"return",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | f_ratios | Calculate f_ON, and f_OFF as defined in van Straten et al. 2012 equations 2 and 3
Parameters
----------
calON_obs : str
Path to filterbank file (any format) for observation ON the calibrator source
calOFF_obs : str
Path to filterbank file (any format) for observation OFF the calibrator ... | blimpy/calib_utils/fluxcal.py | def f_ratios(calON_obs,calOFF_obs,chan_per_coarse,**kwargs):
'''
Calculate f_ON, and f_OFF as defined in van Straten et al. 2012 equations 2 and 3
Parameters
----------
calON_obs : str
Path to filterbank file (any format) for observation ON the calibrator source
calOFF_obs : str
... | def f_ratios(calON_obs,calOFF_obs,chan_per_coarse,**kwargs):
'''
Calculate f_ON, and f_OFF as defined in van Straten et al. 2012 equations 2 and 3
Parameters
----------
calON_obs : str
Path to filterbank file (any format) for observation ON the calibrator source
calOFF_obs : str
... | [
"Calculate",
"f_ON",
"and",
"f_OFF",
"as",
"defined",
"in",
"van",
"Straten",
"et",
"al",
".",
"2012",
"equations",
"2",
"and",
"3"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L181-L199 | [
"def",
"f_ratios",
"(",
"calON_obs",
",",
"calOFF_obs",
",",
"chan_per_coarse",
",",
"*",
"*",
"kwargs",
")",
":",
"#Calculate noise diode ON and noise diode OFF spectra (H and L) for both observations",
"L_ON",
",",
"H_ON",
"=",
"integrate_calib",
"(",
"calON_obs",
",",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | diode_spec | Calculate the coarse channel spectrum and system temperature of the noise diode in Jy given two noise diode
measurements ON and OFF the calibrator source with the same frequency and time resolution
Parameters
----------
calON_obs : str
(see f_ratios() above)
calOFF_obs : str
(see f_... | blimpy/calib_utils/fluxcal.py | def diode_spec(calON_obs,calOFF_obs,calflux,calfreq,spec_in,average=True,oneflux=False,**kwargs):
'''
Calculate the coarse channel spectrum and system temperature of the noise diode in Jy given two noise diode
measurements ON and OFF the calibrator source with the same frequency and time resolution
Par... | def diode_spec(calON_obs,calOFF_obs,calflux,calfreq,spec_in,average=True,oneflux=False,**kwargs):
'''
Calculate the coarse channel spectrum and system temperature of the noise diode in Jy given two noise diode
measurements ON and OFF the calibrator source with the same frequency and time resolution
Par... | [
"Calculate",
"the",
"coarse",
"channel",
"spectrum",
"and",
"system",
"temperature",
"of",
"the",
"noise",
"diode",
"in",
"Jy",
"given",
"two",
"noise",
"diode",
"measurements",
"ON",
"and",
"OFF",
"the",
"calibrator",
"source",
"with",
"the",
"same",
"frequen... | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L202-L243 | [
"def",
"diode_spec",
"(",
"calON_obs",
",",
"calOFF_obs",
",",
"calflux",
",",
"calfreq",
",",
"spec_in",
",",
"average",
"=",
"True",
",",
"oneflux",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"#Load frequencies and calculate number of channels per coarse c... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | get_Tsys | Returns frequency dependent system temperature given observations on and off a calibrator source
Parameters
----------
(See diode_spec()) | blimpy/calib_utils/fluxcal.py | def get_Tsys(calON_obs,calOFF_obs,calflux,calfreq,spec_in,oneflux=False,**kwargs):
'''
Returns frequency dependent system temperature given observations on and off a calibrator source
Parameters
----------
(See diode_spec())
'''
return diode_spec(calON_obs,calOFF_obs,calflux,calfreq,spec_in... | def get_Tsys(calON_obs,calOFF_obs,calflux,calfreq,spec_in,oneflux=False,**kwargs):
'''
Returns frequency dependent system temperature given observations on and off a calibrator source
Parameters
----------
(See diode_spec())
'''
return diode_spec(calON_obs,calOFF_obs,calflux,calfreq,spec_in... | [
"Returns",
"frequency",
"dependent",
"system",
"temperature",
"given",
"observations",
"on",
"and",
"off",
"a",
"calibrator",
"source"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L245-L253 | [
"def",
"get_Tsys",
"(",
"calON_obs",
",",
"calOFF_obs",
",",
"calflux",
",",
"calfreq",
",",
"spec_in",
",",
"oneflux",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"diode_spec",
"(",
"calON_obs",
",",
"calOFF_obs",
",",
"calflux",
",",
"ca... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | calibrate_fluxes | Produce calibrated Stokes I for an observation given a noise diode
measurement on the source and a diode spectrum with the same number of
coarse channels
Parameters
----------
main_obs_name : str
Path to filterbank file containing final data to be calibrated
dio_name : str
Path ... | blimpy/calib_utils/fluxcal.py | def calibrate_fluxes(main_obs_name,dio_name,dspec,Tsys,fullstokes=False,**kwargs):
'''
Produce calibrated Stokes I for an observation given a noise diode
measurement on the source and a diode spectrum with the same number of
coarse channels
Parameters
----------
main_obs_name : str
... | def calibrate_fluxes(main_obs_name,dio_name,dspec,Tsys,fullstokes=False,**kwargs):
'''
Produce calibrated Stokes I for an observation given a noise diode
measurement on the source and a diode spectrum with the same number of
coarse channels
Parameters
----------
main_obs_name : str
... | [
"Produce",
"calibrated",
"Stokes",
"I",
"for",
"an",
"observation",
"given",
"a",
"noise",
"diode",
"measurement",
"on",
"the",
"source",
"and",
"a",
"diode",
"spectrum",
"with",
"the",
"same",
"number",
"of",
"coarse",
"channels"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/fluxcal.py#L255-L307 | [
"def",
"calibrate_fluxes",
"(",
"main_obs_name",
",",
"dio_name",
",",
"dspec",
",",
"Tsys",
",",
"fullstokes",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"#Find folded spectra of the target source with the noise diode ON and OFF",
"main_obs",
"=",
"Waterfall",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | len_header | Return the length of the blimpy header, in bytes
Args:
filename (str): name of file to open
Returns:
idx_end (int): length of header, in bytes | blimpy/sigproc.py | def len_header(filename):
""" Return the length of the blimpy header, in bytes
Args:
filename (str): name of file to open
Returns:
idx_end (int): length of header, in bytes
"""
with open(filename, 'rb') as f:
header_sub_count = 0
eoh_found = False
while not... | def len_header(filename):
""" Return the length of the blimpy header, in bytes
Args:
filename (str): name of file to open
Returns:
idx_end (int): length of header, in bytes
"""
with open(filename, 'rb') as f:
header_sub_count = 0
eoh_found = False
while not... | [
"Return",
"the",
"length",
"of",
"the",
"blimpy",
"header",
"in",
"bytes"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L78-L99 | [
"def",
"len_header",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"header_sub_count",
"=",
"0",
"eoh_found",
"=",
"False",
"while",
"not",
"eoh_found",
":",
"header_sub",
"=",
"f",
".",
"read",
"(",
"512... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | is_filterbank | Open file and confirm if it is a filterbank file or not. | blimpy/sigproc.py | def is_filterbank(filename):
""" Open file and confirm if it is a filterbank file or not. """
with open(filename, 'rb') as fh:
is_fil = True
# Check this is a blimpy file
try:
keyword, value, idx = read_next_header_keyword(fh)
try:
assert keyword ... | def is_filterbank(filename):
""" Open file and confirm if it is a filterbank file or not. """
with open(filename, 'rb') as fh:
is_fil = True
# Check this is a blimpy file
try:
keyword, value, idx = read_next_header_keyword(fh)
try:
assert keyword ... | [
"Open",
"file",
"and",
"confirm",
"if",
"it",
"is",
"a",
"filterbank",
"file",
"or",
"not",
"."
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L143-L157 | [
"def",
"is_filterbank",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fh",
":",
"is_fil",
"=",
"True",
"# Check this is a blimpy file",
"try",
":",
"keyword",
",",
"value",
",",
"idx",
"=",
"read_next_header_keyword",
"... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | read_header | Read blimpy header and return a Python dictionary of key:value pairs
Args:
filename (str): name of file to open
Optional args:
return_idxs (bool): Default False. If true, returns the file offset indexes
for values
returns | blimpy/sigproc.py | def read_header(filename, return_idxs=False):
""" Read blimpy header and return a Python dictionary of key:value pairs
Args:
filename (str): name of file to open
Optional args:
return_idxs (bool): Default False. If true, returns the file offset indexes
for value... | def read_header(filename, return_idxs=False):
""" Read blimpy header and return a Python dictionary of key:value pairs
Args:
filename (str): name of file to open
Optional args:
return_idxs (bool): Default False. If true, returns the file offset indexes
for value... | [
"Read",
"blimpy",
"header",
"and",
"return",
"a",
"Python",
"dictionary",
"of",
"key",
":",
"value",
"pairs"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L160-L196 | [
"def",
"read_header",
"(",
"filename",
",",
"return_idxs",
"=",
"False",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fh",
":",
"header_dict",
"=",
"{",
"}",
"header_idxs",
"=",
"{",
"}",
"# Check this is a blimpy file",
"keyword",
"... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | fix_header | Apply a quick patch-up to a Filterbank header by overwriting a header value
Args:
filename (str): name of file to open and fix. WILL BE MODIFIED.
keyword (stt): header keyword to update
new_value (long, double, angle or string): New value to write.
Notes:
This will overwrite ... | blimpy/sigproc.py | def fix_header(filename, keyword, new_value):
""" Apply a quick patch-up to a Filterbank header by overwriting a header value
Args:
filename (str): name of file to open and fix. WILL BE MODIFIED.
keyword (stt): header keyword to update
new_value (long, double, angle or string): New va... | def fix_header(filename, keyword, new_value):
""" Apply a quick patch-up to a Filterbank header by overwriting a header value
Args:
filename (str): name of file to open and fix. WILL BE MODIFIED.
keyword (stt): header keyword to update
new_value (long, double, angle or string): New va... | [
"Apply",
"a",
"quick",
"patch",
"-",
"up",
"to",
"a",
"Filterbank",
"header",
"by",
"overwriting",
"a",
"header",
"value"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L198-L240 | [
"def",
"fix_header",
"(",
"filename",
",",
"keyword",
",",
"new_value",
")",
":",
"# Read header data and return indexes of data offsets in file",
"hd",
"=",
"read_header",
"(",
"filename",
")",
"hi",
"=",
"read_header",
"(",
"filename",
",",
"return_idxs",
"=",
"Tr... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | fil_double_to_angle | Reads a little-endian double in ddmmss.s (or hhmmss.s) format and then
converts to Float degrees (or hours). This is primarily used to read
src_raj and src_dej header values. | blimpy/sigproc.py | def fil_double_to_angle(angle):
""" Reads a little-endian double in ddmmss.s (or hhmmss.s) format and then
converts to Float degrees (or hours). This is primarily used to read
src_raj and src_dej header values. """
negative = (angle < 0.0)
angle = np.abs(angle)
dd = np.floor((angl... | def fil_double_to_angle(angle):
""" Reads a little-endian double in ddmmss.s (or hhmmss.s) format and then
converts to Float degrees (or hours). This is primarily used to read
src_raj and src_dej header values. """
negative = (angle < 0.0)
angle = np.abs(angle)
dd = np.floor((angl... | [
"Reads",
"a",
"little",
"-",
"endian",
"double",
"in",
"ddmmss",
".",
"s",
"(",
"or",
"hhmmss",
".",
"s",
")",
"format",
"and",
"then",
"converts",
"to",
"Float",
"degrees",
"(",
"or",
"hours",
")",
".",
"This",
"is",
"primarily",
"used",
"to",
"read... | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L242-L259 | [
"def",
"fil_double_to_angle",
"(",
"angle",
")",
":",
"negative",
"=",
"(",
"angle",
"<",
"0.0",
")",
"angle",
"=",
"np",
".",
"abs",
"(",
"angle",
")",
"dd",
"=",
"np",
".",
"floor",
"(",
"(",
"angle",
"/",
"10000",
")",
")",
"angle",
"-=",
"100... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | to_sigproc_keyword | Generate a serialized string for a sigproc keyword:value pair
If value=None, just the keyword will be written with no payload.
Data type is inferred by keyword name (via a lookup table)
Args:
keyword (str): Keyword to write
value (None, float, str, double or angle): value to write to file
... | blimpy/sigproc.py | def to_sigproc_keyword(keyword, value=None):
""" Generate a serialized string for a sigproc keyword:value pair
If value=None, just the keyword will be written with no payload.
Data type is inferred by keyword name (via a lookup table)
Args:
keyword (str): Keyword to write
value (None, ... | def to_sigproc_keyword(keyword, value=None):
""" Generate a serialized string for a sigproc keyword:value pair
If value=None, just the keyword will be written with no payload.
Data type is inferred by keyword name (via a lookup table)
Args:
keyword (str): Keyword to write
value (None, ... | [
"Generate",
"a",
"serialized",
"string",
"for",
"a",
"sigproc",
"keyword",
":",
"value",
"pair"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L265-L296 | [
"def",
"to_sigproc_keyword",
"(",
"keyword",
",",
"value",
"=",
"None",
")",
":",
"keyword",
"=",
"bytes",
"(",
"keyword",
")",
"if",
"value",
"is",
"None",
":",
"return",
"np",
".",
"int32",
"(",
"len",
"(",
"keyword",
")",
")",
".",
"tostring",
"("... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | generate_sigproc_header | Generate a serialzed sigproc header which can be written to disk.
Args:
f (Filterbank object): Filterbank object for which to generate header
Returns:
header_str (str): Serialized string corresponding to header | blimpy/sigproc.py | def generate_sigproc_header(f):
""" Generate a serialzed sigproc header which can be written to disk.
Args:
f (Filterbank object): Filterbank object for which to generate header
Returns:
header_str (str): Serialized string corresponding to header
"""
header_string = b''
header... | def generate_sigproc_header(f):
""" Generate a serialzed sigproc header which can be written to disk.
Args:
f (Filterbank object): Filterbank object for which to generate header
Returns:
header_str (str): Serialized string corresponding to header
"""
header_string = b''
header... | [
"Generate",
"a",
"serialzed",
"sigproc",
"header",
"which",
"can",
"be",
"written",
"to",
"disk",
"."
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L298-L324 | [
"def",
"generate_sigproc_header",
"(",
"f",
")",
":",
"header_string",
"=",
"b''",
"header_string",
"+=",
"to_sigproc_keyword",
"(",
"b'HEADER_START'",
")",
"for",
"keyword",
"in",
"f",
".",
"header",
".",
"keys",
"(",
")",
":",
"if",
"keyword",
"==",
"b'src... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | to_sigproc_angle | Convert an astropy.Angle to the ridiculous sigproc angle format string. | blimpy/sigproc.py | def to_sigproc_angle(angle_val):
""" Convert an astropy.Angle to the ridiculous sigproc angle format string. """
x = str(angle_val)
if '.' in x:
if 'h' in x:
d, m, s, ss = int(x[0:x.index('h')]), int(x[x.index('h')+1:x.index('m')]), \
int(x[x.index('m')+1:x.index('.'... | def to_sigproc_angle(angle_val):
""" Convert an astropy.Angle to the ridiculous sigproc angle format string. """
x = str(angle_val)
if '.' in x:
if 'h' in x:
d, m, s, ss = int(x[0:x.index('h')]), int(x[x.index('h')+1:x.index('m')]), \
int(x[x.index('m')+1:x.index('.'... | [
"Convert",
"an",
"astropy",
".",
"Angle",
"to",
"the",
"ridiculous",
"sigproc",
"angle",
"format",
"string",
"."
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L327-L347 | [
"def",
"to_sigproc_angle",
"(",
"angle_val",
")",
":",
"x",
"=",
"str",
"(",
"angle_val",
")",
"if",
"'.'",
"in",
"x",
":",
"if",
"'h'",
"in",
"x",
":",
"d",
",",
"m",
",",
"s",
",",
"ss",
"=",
"int",
"(",
"x",
"[",
"0",
":",
"x",
".",
"ind... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | calc_n_ints_in_file | Calculate number of integrations in a given file | blimpy/sigproc.py | def calc_n_ints_in_file(filename):
""" Calculate number of integrations in a given file """
# Load binary data
h = read_header(filename)
n_bytes = int(h[b'nbits'] / 8)
n_chans = h[b'nchans']
n_ifs = h[b'nifs']
idx_data = len_header(filename)
f = open(filename, 'rb')
f.seek(idx_da... | def calc_n_ints_in_file(filename):
""" Calculate number of integrations in a given file """
# Load binary data
h = read_header(filename)
n_bytes = int(h[b'nbits'] / 8)
n_chans = h[b'nchans']
n_ifs = h[b'nifs']
idx_data = len_header(filename)
f = open(filename, 'rb')
f.seek(idx_da... | [
"Calculate",
"number",
"of",
"integrations",
"in",
"a",
"given",
"file"
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L350-L369 | [
"def",
"calc_n_ints_in_file",
"(",
"filename",
")",
":",
"# Load binary data",
"h",
"=",
"read_header",
"(",
"filename",
")",
"n_bytes",
"=",
"int",
"(",
"h",
"[",
"b'nbits'",
"]",
"/",
"8",
")",
"n_chans",
"=",
"h",
"[",
"b'nchans'",
"]",
"n_ifs",
"=",
... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | make_fil_file | Converts file to Sigproc filterbank (.fil) format. Default saves output in current dir. | blimpy/h52fil.py | def make_fil_file(filename,out_dir='./', new_filename=None, max_load = None):
''' Converts file to Sigproc filterbank (.fil) format. Default saves output in current dir.
'''
fil_file = Waterfall(filename, max_load = max_load)
if not new_filename:
new_filename = out_dir+filename.replace('.h5','... | def make_fil_file(filename,out_dir='./', new_filename=None, max_load = None):
''' Converts file to Sigproc filterbank (.fil) format. Default saves output in current dir.
'''
fil_file = Waterfall(filename, max_load = max_load)
if not new_filename:
new_filename = out_dir+filename.replace('.h5','... | [
"Converts",
"file",
"to",
"Sigproc",
"filterbank",
"(",
".",
"fil",
")",
"format",
".",
"Default",
"saves",
"output",
"in",
"current",
"dir",
"."
] | UCBerkeleySETI/blimpy | python | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/h52fil.py#L37-L48 | [
"def",
"make_fil_file",
"(",
"filename",
",",
"out_dir",
"=",
"'./'",
",",
"new_filename",
"=",
"None",
",",
"max_load",
"=",
"None",
")",
":",
"fil_file",
"=",
"Waterfall",
"(",
"filename",
",",
"max_load",
"=",
"max_load",
")",
"if",
"not",
"new_filename... | b8822d3e3e911944370d84371a91fa0c29e9772e |
test | Traceback.to_dict | Convert a Traceback into a dictionary representation | src/tblib/__init__.py | def to_dict(self):
"""Convert a Traceback into a dictionary representation"""
if self.tb_next is None:
tb_next = None
else:
tb_next = self.tb_next.to_dict()
code = {
'co_filename': self.tb_frame.f_code.co_filename,
'co_name': self.tb_frame... | def to_dict(self):
"""Convert a Traceback into a dictionary representation"""
if self.tb_next is None:
tb_next = None
else:
tb_next = self.tb_next.to_dict()
code = {
'co_filename': self.tb_frame.f_code.co_filename,
'co_name': self.tb_frame... | [
"Convert",
"a",
"Traceback",
"into",
"a",
"dictionary",
"representation"
] | ionelmc/python-tblib | python | https://github.com/ionelmc/python-tblib/blob/00be69aa97e1eb1c09282b1cdb72539c947d4515/src/tblib/__init__.py#L141-L160 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"if",
"self",
".",
"tb_next",
"is",
"None",
":",
"tb_next",
"=",
"None",
"else",
":",
"tb_next",
"=",
"self",
".",
"tb_next",
".",
"to_dict",
"(",
")",
"code",
"=",
"{",
"'co_filename'",
":",
"self",
".",
"t... | 00be69aa97e1eb1c09282b1cdb72539c947d4515 |
test | make_rr_subparser | Make a subparser for a given type of DNS record | blockstack_zones/parse_zone_file.py | def make_rr_subparser(subparsers, rec_type, args_and_types):
"""
Make a subparser for a given type of DNS record
"""
sp = subparsers.add_parser(rec_type)
sp.add_argument("name", type=str)
sp.add_argument("ttl", type=int, nargs='?')
sp.add_argument(rec_type, type=str)
for my_spec in arg... | def make_rr_subparser(subparsers, rec_type, args_and_types):
"""
Make a subparser for a given type of DNS record
"""
sp = subparsers.add_parser(rec_type)
sp.add_argument("name", type=str)
sp.add_argument("ttl", type=int, nargs='?')
sp.add_argument(rec_type, type=str)
for my_spec in arg... | [
"Make",
"a",
"subparser",
"for",
"a",
"given",
"type",
"of",
"DNS",
"record"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L32-L49 | [
"def",
"make_rr_subparser",
"(",
"subparsers",
",",
"rec_type",
",",
"args_and_types",
")",
":",
"sp",
"=",
"subparsers",
".",
"add_parser",
"(",
"rec_type",
")",
"sp",
".",
"add_argument",
"(",
"\"name\"",
",",
"type",
"=",
"str",
")",
"sp",
".",
"add_arg... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | make_parser | Make an ArgumentParser that accepts DNS RRs | blockstack_zones/parse_zone_file.py | def make_parser():
"""
Make an ArgumentParser that accepts DNS RRs
"""
line_parser = ZonefileLineParser()
subparsers = line_parser.add_subparsers()
# parse $ORIGIN
sp = subparsers.add_parser("$ORIGIN")
sp.add_argument("$ORIGIN", type=str)
# parse $TTL
sp = subparsers.add_parser... | def make_parser():
"""
Make an ArgumentParser that accepts DNS RRs
"""
line_parser = ZonefileLineParser()
subparsers = line_parser.add_subparsers()
# parse $ORIGIN
sp = subparsers.add_parser("$ORIGIN")
sp.add_argument("$ORIGIN", type=str)
# parse $TTL
sp = subparsers.add_parser... | [
"Make",
"an",
"ArgumentParser",
"that",
"accepts",
"DNS",
"RRs"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L60-L94 | [
"def",
"make_parser",
"(",
")",
":",
"line_parser",
"=",
"ZonefileLineParser",
"(",
")",
"subparsers",
"=",
"line_parser",
".",
"add_subparsers",
"(",
")",
"# parse $ORIGIN",
"sp",
"=",
"subparsers",
".",
"add_parser",
"(",
"\"$ORIGIN\"",
")",
"sp",
".",
"add_... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | tokenize_line | Tokenize a line:
* split tokens on whitespace
* treat quoted strings as a single token
* drop comments
* handle escaped spaces and comment delimiters | blockstack_zones/parse_zone_file.py | def tokenize_line(line):
"""
Tokenize a line:
* split tokens on whitespace
* treat quoted strings as a single token
* drop comments
* handle escaped spaces and comment delimiters
"""
ret = []
escape = False
quote = False
tokbuf = ""
ll = list(line)
while len(ll) > 0:
... | def tokenize_line(line):
"""
Tokenize a line:
* split tokens on whitespace
* treat quoted strings as a single token
* drop comments
* handle escaped spaces and comment delimiters
"""
ret = []
escape = False
quote = False
tokbuf = ""
ll = list(line)
while len(ll) > 0:
... | [
"Tokenize",
"a",
"line",
":",
"*",
"split",
"tokens",
"on",
"whitespace",
"*",
"treat",
"quoted",
"strings",
"as",
"a",
"single",
"token",
"*",
"drop",
"comments",
"*",
"handle",
"escaped",
"spaces",
"and",
"comment",
"delimiters"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L97-L160 | [
"def",
"tokenize_line",
"(",
"line",
")",
":",
"ret",
"=",
"[",
"]",
"escape",
"=",
"False",
"quote",
"=",
"False",
"tokbuf",
"=",
"\"\"",
"ll",
"=",
"list",
"(",
"line",
")",
"while",
"len",
"(",
"ll",
")",
">",
"0",
":",
"c",
"=",
"ll",
".",
... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | serialize | Serialize tokens:
* quote whitespace-containing tokens
* escape semicolons | blockstack_zones/parse_zone_file.py | def serialize(tokens):
"""
Serialize tokens:
* quote whitespace-containing tokens
* escape semicolons
"""
ret = []
for tok in tokens:
if " " in tok:
tok = '"%s"' % tok
if ";" in tok:
tok = tok.replace(";", "\;")
ret.append(tok)
return " ... | def serialize(tokens):
"""
Serialize tokens:
* quote whitespace-containing tokens
* escape semicolons
"""
ret = []
for tok in tokens:
if " " in tok:
tok = '"%s"' % tok
if ";" in tok:
tok = tok.replace(";", "\;")
ret.append(tok)
return " ... | [
"Serialize",
"tokens",
":",
"*",
"quote",
"whitespace",
"-",
"containing",
"tokens",
"*",
"escape",
"semicolons"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L163-L179 | [
"def",
"serialize",
"(",
"tokens",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"tok",
"in",
"tokens",
":",
"if",
"\" \"",
"in",
"tok",
":",
"tok",
"=",
"'\"%s\"'",
"%",
"tok",
"if",
"\";\"",
"in",
"tok",
":",
"tok",
"=",
"tok",
".",
"replace",
"(",
... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | remove_comments | Remove comments from a zonefile | blockstack_zones/parse_zone_file.py | def remove_comments(text):
"""
Remove comments from a zonefile
"""
ret = []
lines = text.split("\n")
for line in lines:
if len(line) == 0:
continue
line = serialize(tokenize_line(line))
ret.append(line)
return "\n".join(ret) | def remove_comments(text):
"""
Remove comments from a zonefile
"""
ret = []
lines = text.split("\n")
for line in lines:
if len(line) == 0:
continue
line = serialize(tokenize_line(line))
ret.append(line)
return "\n".join(ret) | [
"Remove",
"comments",
"from",
"a",
"zonefile"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L182-L195 | [
"def",
"remove_comments",
"(",
"text",
")",
":",
"ret",
"=",
"[",
"]",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"for",
"line",
"in",
"lines",
":",
"if",
"len",
"(",
"line",
")",
"==",
"0",
":",
"continue",
"line",
"=",
"serialize",
... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | flatten | Flatten the text:
* make sure each record is on one line.
* remove parenthesis | blockstack_zones/parse_zone_file.py | def flatten(text):
"""
Flatten the text:
* make sure each record is on one line.
* remove parenthesis
"""
lines = text.split("\n")
# tokens: sequence of non-whitespace separated by '' where a newline was
tokens = []
for l in lines:
if len(l) == 0:
continue
... | def flatten(text):
"""
Flatten the text:
* make sure each record is on one line.
* remove parenthesis
"""
lines = text.split("\n")
# tokens: sequence of non-whitespace separated by '' where a newline was
tokens = []
for l in lines:
if len(l) == 0:
continue
... | [
"Flatten",
"the",
"text",
":",
"*",
"make",
"sure",
"each",
"record",
"is",
"on",
"one",
"line",
".",
"*",
"remove",
"parenthesis"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L198-L241 | [
"def",
"flatten",
"(",
"text",
")",
":",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"# tokens: sequence of non-whitespace separated by '' where a newline was",
"tokens",
"=",
"[",
"]",
"for",
"l",
"in",
"lines",
":",
"if",
"len",
"(",
"l",
")",
... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | remove_class | Remove the CLASS from each DNS record, if present.
The only class that gets used today (for all intents
and purposes) is 'IN'. | blockstack_zones/parse_zone_file.py | def remove_class(text):
"""
Remove the CLASS from each DNS record, if present.
The only class that gets used today (for all intents
and purposes) is 'IN'.
"""
# see RFC 1035 for list of classes
lines = text.split("\n")
ret = []
for line in lines:
tokens = tokenize_line(line)... | def remove_class(text):
"""
Remove the CLASS from each DNS record, if present.
The only class that gets used today (for all intents
and purposes) is 'IN'.
"""
# see RFC 1035 for list of classes
lines = text.split("\n")
ret = []
for line in lines:
tokens = tokenize_line(line)... | [
"Remove",
"the",
"CLASS",
"from",
"each",
"DNS",
"record",
"if",
"present",
".",
"The",
"only",
"class",
"that",
"gets",
"used",
"today",
"(",
"for",
"all",
"intents",
"and",
"purposes",
")",
"is",
"IN",
"."
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L244-L269 | [
"def",
"remove_class",
"(",
"text",
")",
":",
"# see RFC 1035 for list of classes",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"ret",
"=",
"[",
"]",
"for",
"line",
"in",
"lines",
":",
"tokens",
"=",
"tokenize_line",
"(",
"line",
")",
"tokens_... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | add_default_name | Go through each line of the text and ensure that
a name is defined. Use '@' if there is none. | blockstack_zones/parse_zone_file.py | def add_default_name(text):
"""
Go through each line of the text and ensure that
a name is defined. Use '@' if there is none.
"""
global SUPPORTED_RECORDS
lines = text.split("\n")
ret = []
for line in lines:
tokens = tokenize_line(line)
if len(tokens) == 0:
... | def add_default_name(text):
"""
Go through each line of the text and ensure that
a name is defined. Use '@' if there is none.
"""
global SUPPORTED_RECORDS
lines = text.split("\n")
ret = []
for line in lines:
tokens = tokenize_line(line)
if len(tokens) == 0:
... | [
"Go",
"through",
"each",
"line",
"of",
"the",
"text",
"and",
"ensure",
"that",
"a",
"name",
"is",
"defined",
".",
"Use"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L272-L292 | [
"def",
"add_default_name",
"(",
"text",
")",
":",
"global",
"SUPPORTED_RECORDS",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"ret",
"=",
"[",
"]",
"for",
"line",
"in",
"lines",
":",
"tokens",
"=",
"tokenize_line",
"(",
"line",
")",
"if",
"... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | parse_line | Given the parser, capitalized list of a line's tokens, and the current set of records
parsed so far, parse it into a dictionary.
Return the new set of parsed records.
Raise an exception on error. | blockstack_zones/parse_zone_file.py | def parse_line(parser, record_token, parsed_records):
"""
Given the parser, capitalized list of a line's tokens, and the current set of records
parsed so far, parse it into a dictionary.
Return the new set of parsed records.
Raise an exception on error.
"""
global SUPPORTED_RECORDS
l... | def parse_line(parser, record_token, parsed_records):
"""
Given the parser, capitalized list of a line's tokens, and the current set of records
parsed so far, parse it into a dictionary.
Return the new set of parsed records.
Raise an exception on error.
"""
global SUPPORTED_RECORDS
l... | [
"Given",
"the",
"parser",
"capitalized",
"list",
"of",
"a",
"line",
"s",
"tokens",
"and",
"the",
"current",
"set",
"of",
"records",
"parsed",
"so",
"far",
"parse",
"it",
"into",
"a",
"dictionary",
"."
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L295-L359 | [
"def",
"parse_line",
"(",
"parser",
",",
"record_token",
",",
"parsed_records",
")",
":",
"global",
"SUPPORTED_RECORDS",
"line",
"=",
"\" \"",
".",
"join",
"(",
"record_token",
")",
"# match parser to record type",
"if",
"len",
"(",
"record_token",
")",
">=",
"2... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | parse_lines | Parse a zonefile into a dict.
@text must be flattened--each record must be on one line.
Also, all comments must be removed. | blockstack_zones/parse_zone_file.py | def parse_lines(text, ignore_invalid=False):
"""
Parse a zonefile into a dict.
@text must be flattened--each record must be on one line.
Also, all comments must be removed.
"""
json_zone_file = defaultdict(list)
record_lines = text.split("\n")
parser = make_parser()
for record_line ... | def parse_lines(text, ignore_invalid=False):
"""
Parse a zonefile into a dict.
@text must be flattened--each record must be on one line.
Also, all comments must be removed.
"""
json_zone_file = defaultdict(list)
record_lines = text.split("\n")
parser = make_parser()
for record_line ... | [
"Parse",
"a",
"zonefile",
"into",
"a",
"dict",
"."
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L362-L382 | [
"def",
"parse_lines",
"(",
"text",
",",
"ignore_invalid",
"=",
"False",
")",
":",
"json_zone_file",
"=",
"defaultdict",
"(",
"list",
")",
"record_lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"parser",
"=",
"make_parser",
"(",
")",
"for",
"record... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | parse_zone_file | Parse a zonefile into a dict | blockstack_zones/parse_zone_file.py | def parse_zone_file(text, ignore_invalid=False):
"""
Parse a zonefile into a dict
"""
text = remove_comments(text)
text = flatten(text)
text = remove_class(text)
text = add_default_name(text)
json_zone_file = parse_lines(text, ignore_invalid=ignore_invalid)
return json_zone_file | def parse_zone_file(text, ignore_invalid=False):
"""
Parse a zonefile into a dict
"""
text = remove_comments(text)
text = flatten(text)
text = remove_class(text)
text = add_default_name(text)
json_zone_file = parse_lines(text, ignore_invalid=ignore_invalid)
return json_zone_file | [
"Parse",
"a",
"zonefile",
"into",
"a",
"dict"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/parse_zone_file.py#L385-L394 | [
"def",
"parse_zone_file",
"(",
"text",
",",
"ignore_invalid",
"=",
"False",
")",
":",
"text",
"=",
"remove_comments",
"(",
"text",
")",
"text",
"=",
"flatten",
"(",
"text",
")",
"text",
"=",
"remove_class",
"(",
"text",
")",
"text",
"=",
"add_default_name"... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | make_zone_file | Generate the DNS zonefile, given a json-encoded description of the
zone file (@json_zone_file) and the template to fill in (@template)
json_zone_file = {
"$origin": origin server,
"$ttl": default time-to-live,
"soa": [ soa records ],
"ns": [ ns records ],
"a"... | blockstack_zones/make_zone_file.py | def make_zone_file(json_zone_file_input, origin=None, ttl=None, template=None):
"""
Generate the DNS zonefile, given a json-encoded description of the
zone file (@json_zone_file) and the template to fill in (@template)
json_zone_file = {
"$origin": origin server,
"$ttl": default time... | def make_zone_file(json_zone_file_input, origin=None, ttl=None, template=None):
"""
Generate the DNS zonefile, given a json-encoded description of the
zone file (@json_zone_file) and the template to fill in (@template)
json_zone_file = {
"$origin": origin server,
"$ttl": default time... | [
"Generate",
"the",
"DNS",
"zonefile",
"given",
"a",
"json",
"-",
"encoded",
"description",
"of",
"the",
"zone",
"file",
"(",
"@json_zone_file",
")",
"and",
"the",
"template",
"to",
"fill",
"in",
"(",
"@template",
")"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/make_zone_file.py#L10-L69 | [
"def",
"make_zone_file",
"(",
"json_zone_file_input",
",",
"origin",
"=",
"None",
",",
"ttl",
"=",
"None",
",",
"template",
"=",
"None",
")",
":",
"if",
"template",
"is",
"None",
":",
"template",
"=",
"DEFAULT_TEMPLATE",
"[",
":",
"]",
"# careful...",
"jso... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | process_origin | Replace {$origin} in template with a serialized $ORIGIN record | blockstack_zones/record_processors.py | def process_origin(data, template):
"""
Replace {$origin} in template with a serialized $ORIGIN record
"""
record = ""
if data is not None:
record += "$ORIGIN %s" % data
return template.replace("{$origin}", record) | def process_origin(data, template):
"""
Replace {$origin} in template with a serialized $ORIGIN record
"""
record = ""
if data is not None:
record += "$ORIGIN %s" % data
return template.replace("{$origin}", record) | [
"Replace",
"{",
"$origin",
"}",
"in",
"template",
"with",
"a",
"serialized",
"$ORIGIN",
"record"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L4-L12 | [
"def",
"process_origin",
"(",
"data",
",",
"template",
")",
":",
"record",
"=",
"\"\"",
"if",
"data",
"is",
"not",
"None",
":",
"record",
"+=",
"\"$ORIGIN %s\"",
"%",
"data",
"return",
"template",
".",
"replace",
"(",
"\"{$origin}\"",
",",
"record",
")"
] | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | process_ttl | Replace {$ttl} in template with a serialized $TTL record | blockstack_zones/record_processors.py | def process_ttl(data, template):
"""
Replace {$ttl} in template with a serialized $TTL record
"""
record = ""
if data is not None:
record += "$TTL %s" % data
return template.replace("{$ttl}", record) | def process_ttl(data, template):
"""
Replace {$ttl} in template with a serialized $TTL record
"""
record = ""
if data is not None:
record += "$TTL %s" % data
return template.replace("{$ttl}", record) | [
"Replace",
"{",
"$ttl",
"}",
"in",
"template",
"with",
"a",
"serialized",
"$TTL",
"record"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L15-L23 | [
"def",
"process_ttl",
"(",
"data",
",",
"template",
")",
":",
"record",
"=",
"\"\"",
"if",
"data",
"is",
"not",
"None",
":",
"record",
"+=",
"\"$TTL %s\"",
"%",
"data",
"return",
"template",
".",
"replace",
"(",
"\"{$ttl}\"",
",",
"record",
")"
] | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | process_soa | Replace {SOA} in template with a set of serialized SOA records | blockstack_zones/record_processors.py | def process_soa(data, template):
"""
Replace {SOA} in template with a set of serialized SOA records
"""
record = template[:]
if data is not None:
assert len(data) == 1, "Only support one SOA RR at this time"
data = data[0]
soadat = []
domain_fields = ['mname', ... | def process_soa(data, template):
"""
Replace {SOA} in template with a set of serialized SOA records
"""
record = template[:]
if data is not None:
assert len(data) == 1, "Only support one SOA RR at this time"
data = data[0]
soadat = []
domain_fields = ['mname', ... | [
"Replace",
"{",
"SOA",
"}",
"in",
"template",
"with",
"a",
"set",
"of",
"serialized",
"SOA",
"records"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L26-L72 | [
"def",
"process_soa",
"(",
"data",
",",
"template",
")",
":",
"record",
"=",
"template",
"[",
":",
"]",
"if",
"data",
"is",
"not",
"None",
":",
"assert",
"len",
"(",
"data",
")",
"==",
"1",
",",
"\"Only support one SOA RR at this time\"",
"data",
"=",
"d... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | quote_field | Quote a field in a list of DNS records.
Return the new data records. | blockstack_zones/record_processors.py | def quote_field(data, field):
"""
Quote a field in a list of DNS records.
Return the new data records.
"""
if data is None:
return None
data_dup = copy.deepcopy(data)
for i in xrange(0, len(data_dup)):
data_dup[i][field] = '"%s"' % data_dup[i][field]
data_dup[i][fie... | def quote_field(data, field):
"""
Quote a field in a list of DNS records.
Return the new data records.
"""
if data is None:
return None
data_dup = copy.deepcopy(data)
for i in xrange(0, len(data_dup)):
data_dup[i][field] = '"%s"' % data_dup[i][field]
data_dup[i][fie... | [
"Quote",
"a",
"field",
"in",
"a",
"list",
"of",
"DNS",
"records",
".",
"Return",
"the",
"new",
"data",
"records",
"."
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L75-L88 | [
"def",
"quote_field",
"(",
"data",
",",
"field",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"None",
"data_dup",
"=",
"copy",
".",
"deepcopy",
"(",
"data",
")",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"len",
"(",
"data_dup",
")",
")",
... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | process_rr | Meta method:
Replace $field in template with the serialized $record_type records,
using @record_key from each datum. | blockstack_zones/record_processors.py | def process_rr(data, record_type, record_keys, field, template):
"""
Meta method:
Replace $field in template with the serialized $record_type records,
using @record_key from each datum.
"""
if data is None:
return template.replace(field, "")
if type(record_keys) == list:
pas... | def process_rr(data, record_type, record_keys, field, template):
"""
Meta method:
Replace $field in template with the serialized $record_type records,
using @record_key from each datum.
"""
if data is None:
return template.replace(field, "")
if type(record_keys) == list:
pas... | [
"Meta",
"method",
":",
"Replace",
"$field",
"in",
"template",
"with",
"the",
"serialized",
"$record_type",
"records",
"using"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L91-L124 | [
"def",
"process_rr",
"(",
"data",
",",
"record_type",
",",
"record_keys",
",",
"field",
",",
"template",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"template",
".",
"replace",
"(",
"field",
",",
"\"\"",
")",
"if",
"type",
"(",
"record_keys",
... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | process_txt | Replace {txt} in template with the serialized TXT records | blockstack_zones/record_processors.py | def process_txt(data, template):
"""
Replace {txt} in template with the serialized TXT records
"""
if data is None:
to_process = None
else:
# quote txt
to_process = copy.deepcopy(data)
for datum in to_process:
if isinstance(datum["txt"], list):
... | def process_txt(data, template):
"""
Replace {txt} in template with the serialized TXT records
"""
if data is None:
to_process = None
else:
# quote txt
to_process = copy.deepcopy(data)
for datum in to_process:
if isinstance(datum["txt"], list):
... | [
"Replace",
"{",
"txt",
"}",
"in",
"template",
"with",
"the",
"serialized",
"TXT",
"records"
] | blockstack/zone-file-py | python | https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L176-L191 | [
"def",
"process_txt",
"(",
"data",
",",
"template",
")",
":",
"if",
"data",
"is",
"None",
":",
"to_process",
"=",
"None",
"else",
":",
"# quote txt",
"to_process",
"=",
"copy",
".",
"deepcopy",
"(",
"data",
")",
"for",
"datum",
"in",
"to_process",
":",
... | c1078c8c3c28f0881bc9a3af53d4972c4a6862d0 |
test | parse_schema_string | Load and return a PySchema class from an avsc string | pyschema_extensions/avro_schema_parser.py | def parse_schema_string(schema_string):
"""
Load and return a PySchema class from an avsc string
"""
if isinstance(schema_string, str):
schema_string = schema_string.decode("utf8")
schema_struct = json.loads(schema_string)
return AvroSchemaParser().parse_schema_struct(schema_struct) | def parse_schema_string(schema_string):
"""
Load and return a PySchema class from an avsc string
"""
if isinstance(schema_string, str):
schema_string = schema_string.decode("utf8")
schema_struct = json.loads(schema_string)
return AvroSchemaParser().parse_schema_struct(schema_struct) | [
"Load",
"and",
"return",
"a",
"PySchema",
"class",
"from",
"an",
"avsc",
"string"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema_extensions/avro_schema_parser.py#L49-L57 | [
"def",
"parse_schema_string",
"(",
"schema_string",
")",
":",
"if",
"isinstance",
"(",
"schema_string",
",",
"str",
")",
":",
"schema_string",
"=",
"schema_string",
".",
"decode",
"(",
"\"utf8\"",
")",
"schema_struct",
"=",
"json",
".",
"loads",
"(",
"schema_s... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | to_python_package | This function can be used to build a python package representation of pyschema classes.
One module is created per namespace in a package matching the namespace hierarchy.
Args:
classes: A collection of classes to build the package from
target_folder: Root folder of the package
parent_pa... | pyschema/source_generation.py | def to_python_package(classes, target_folder, parent_package=None, indent=DEFAULT_INDENT):
'''
This function can be used to build a python package representation of pyschema classes.
One module is created per namespace in a package matching the namespace hierarchy.
Args:
classes: A collection o... | def to_python_package(classes, target_folder, parent_package=None, indent=DEFAULT_INDENT):
'''
This function can be used to build a python package representation of pyschema classes.
One module is created per namespace in a package matching the namespace hierarchy.
Args:
classes: A collection o... | [
"This",
"function",
"can",
"be",
"used",
"to",
"build",
"a",
"python",
"package",
"representation",
"of",
"pyschema",
"classes",
".",
"One",
"module",
"is",
"created",
"per",
"namespace",
"in",
"a",
"package",
"matching",
"the",
"namespace",
"hierarchy",
"."
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/source_generation.py#L158-L170 | [
"def",
"to_python_package",
"(",
"classes",
",",
"target_folder",
",",
"parent_package",
"=",
"None",
",",
"indent",
"=",
"DEFAULT_INDENT",
")",
":",
"PackageBuilder",
"(",
"target_folder",
",",
"parent_package",
",",
"indent",
")",
".",
"from_classes_with_refs",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | _class_source | Generate Python source code for one specific class
Doesn't include or take into account any dependencies between record types | pyschema/source_generation.py | def _class_source(schema, indent):
"""Generate Python source code for one specific class
Doesn't include or take into account any dependencies between record types
"""
def_pattern = (
"class {class_name}(pyschema.Record):\n"
"{indent}# WARNING: This class was generated by pyschema.to_p... | def _class_source(schema, indent):
"""Generate Python source code for one specific class
Doesn't include or take into account any dependencies between record types
"""
def_pattern = (
"class {class_name}(pyschema.Record):\n"
"{indent}# WARNING: This class was generated by pyschema.to_p... | [
"Generate",
"Python",
"source",
"code",
"for",
"one",
"specific",
"class"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/source_generation.py#L193-L224 | [
"def",
"_class_source",
"(",
"schema",
",",
"indent",
")",
":",
"def_pattern",
"=",
"(",
"\"class {class_name}(pyschema.Record):\\n\"",
"\"{indent}# WARNING: This class was generated by pyschema.to_python_source\\n\"",
"\"{indent}# there is a risk that any modification made to this class w... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | no_auto_store | Temporarily disable automatic registration of records in the auto_store
Decorator factory. This is _NOT_ thread safe
>>> @no_auto_store()
... class BarRecord(Record):
... pass
>>> BarRecord in auto_store
False | pyschema/core.py | def no_auto_store():
""" Temporarily disable automatic registration of records in the auto_store
Decorator factory. This is _NOT_ thread safe
>>> @no_auto_store()
... class BarRecord(Record):
... pass
>>> BarRecord in auto_store
False
"""
original_auto_register_value = PySchem... | def no_auto_store():
""" Temporarily disable automatic registration of records in the auto_store
Decorator factory. This is _NOT_ thread safe
>>> @no_auto_store()
... class BarRecord(Record):
... pass
>>> BarRecord in auto_store
False
"""
original_auto_register_value = PySchem... | [
"Temporarily",
"disable",
"automatic",
"registration",
"of",
"records",
"in",
"the",
"auto_store"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L416-L435 | [
"def",
"no_auto_store",
"(",
")",
":",
"original_auto_register_value",
"=",
"PySchema",
".",
"auto_register",
"disable_auto_register",
"(",
")",
"def",
"decorator",
"(",
"cls",
")",
":",
"PySchema",
".",
"auto_register",
"=",
"original_auto_register_value",
"return",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | to_json_compatible | Dump record in json-encodable object format | pyschema/core.py | def to_json_compatible(record):
"Dump record in json-encodable object format"
d = {}
for fname, f in record._fields.iteritems():
val = getattr(record, fname)
if val is not None:
d[fname] = f.dump(val)
return d | def to_json_compatible(record):
"Dump record in json-encodable object format"
d = {}
for fname, f in record._fields.iteritems():
val = getattr(record, fname)
if val is not None:
d[fname] = f.dump(val)
return d | [
"Dump",
"record",
"in",
"json",
"-",
"encodable",
"object",
"format"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L502-L509 | [
"def",
"to_json_compatible",
"(",
"record",
")",
":",
"d",
"=",
"{",
"}",
"for",
"fname",
",",
"f",
"in",
"record",
".",
"_fields",
".",
"iteritems",
"(",
")",
":",
"val",
"=",
"getattr",
"(",
"record",
",",
"fname",
")",
"if",
"val",
"is",
"not",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | from_json_compatible | Load from json-encodable | pyschema/core.py | def from_json_compatible(schema, dct):
"Load from json-encodable"
kwargs = {}
for key in dct:
field_type = schema._fields.get(key)
if field_type is None:
raise ParseError("Unexpected field encountered in line for record %s: %s" % (schema.__name__, key))
kwargs[key] = fie... | def from_json_compatible(schema, dct):
"Load from json-encodable"
kwargs = {}
for key in dct:
field_type = schema._fields.get(key)
if field_type is None:
raise ParseError("Unexpected field encountered in line for record %s: %s" % (schema.__name__, key))
kwargs[key] = fie... | [
"Load",
"from",
"json",
"-",
"encodable"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L512-L522 | [
"def",
"from_json_compatible",
"(",
"schema",
",",
"dct",
")",
":",
"kwargs",
"=",
"{",
"}",
"for",
"key",
"in",
"dct",
":",
"field_type",
"=",
"schema",
".",
"_fields",
".",
"get",
"(",
"key",
")",
"if",
"field_type",
"is",
"None",
":",
"raise",
"Pa... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | load_json_dct | Create a Record instance from a json-compatible dictionary
The dictionary values should have types that are json compatible,
as if just loaded from a json serialized record string.
:param dct:
Python dictionary with key/value pairs for the record
:param record_store:
Record store to u... | pyschema/core.py | def load_json_dct(
dct,
record_store=None,
schema=None,
loader=from_json_compatible
):
""" Create a Record instance from a json-compatible dictionary
The dictionary values should have types that are json compatible,
as if just loaded from a json serialized record string.
... | def load_json_dct(
dct,
record_store=None,
schema=None,
loader=from_json_compatible
):
""" Create a Record instance from a json-compatible dictionary
The dictionary values should have types that are json compatible,
as if just loaded from a json serialized record string.
... | [
"Create",
"a",
"Record",
"instance",
"from",
"a",
"json",
"-",
"compatible",
"dictionary"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L541-L586 | [
"def",
"load_json_dct",
"(",
"dct",
",",
"record_store",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"loader",
"=",
"from_json_compatible",
")",
":",
"if",
"schema",
"is",
"None",
":",
"if",
"record_store",
"is",
"None",
":",
"record_store",
"=",
"auto_s... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | loads | Create a Record instance from a json serialized dictionary
:param s:
String with a json-serialized dictionary
:param record_store:
Record store to use for schema lookups (when $schema field is present)
:param loader:
Function called to fetch attributes from json. Typically shouldn... | pyschema/core.py | def loads(
s,
record_store=None,
schema=None,
loader=from_json_compatible,
record_class=None # deprecated in favor of schema
):
""" Create a Record instance from a json serialized dictionary
:param s:
String with a json-serialized dictionary
:param record_s... | def loads(
s,
record_store=None,
schema=None,
loader=from_json_compatible,
record_class=None # deprecated in favor of schema
):
""" Create a Record instance from a json serialized dictionary
:param s:
String with a json-serialized dictionary
:param record_s... | [
"Create",
"a",
"Record",
"instance",
"from",
"a",
"json",
"serialized",
"dictionary"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L589-L628 | [
"def",
"loads",
"(",
"s",
",",
"record_store",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"loader",
"=",
"from_json_compatible",
",",
"record_class",
"=",
"None",
"# deprecated in favor of schema",
")",
":",
"if",
"record_class",
"is",
"not",
"None",
":",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | SchemaStore.add_record | Add record class to record store for retrieval at record load time.
Can be used as a class decorator | pyschema/core.py | def add_record(self, schema, _bump_stack_level=False):
""" Add record class to record store for retrieval at record load time.
Can be used as a class decorator
"""
full_name = get_full_name(schema)
has_namespace = '.' in full_name
self._force_add(full_name, schema, _... | def add_record(self, schema, _bump_stack_level=False):
""" Add record class to record store for retrieval at record load time.
Can be used as a class decorator
"""
full_name = get_full_name(schema)
has_namespace = '.' in full_name
self._force_add(full_name, schema, _... | [
"Add",
"record",
"class",
"to",
"record",
"store",
"for",
"retrieval",
"at",
"record",
"load",
"time",
"."
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L97-L107 | [
"def",
"add_record",
"(",
"self",
",",
"schema",
",",
"_bump_stack_level",
"=",
"False",
")",
":",
"full_name",
"=",
"get_full_name",
"(",
"schema",
")",
"has_namespace",
"=",
"'.'",
"in",
"full_name",
"self",
".",
"_force_add",
"(",
"full_name",
",",
"schem... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | SchemaStore.get | Will return a matching record or raise KeyError is no record is found.
If the record name is a full name we will first check for a record matching the full name.
If no such record is found any record matching the last part of the full name (without the namespace) will
be returned. | pyschema/core.py | def get(self, record_name):
"""
Will return a matching record or raise KeyError is no record is found.
If the record name is a full name we will first check for a record matching the full name.
If no such record is found any record matching the last part of the full name (without the na... | def get(self, record_name):
"""
Will return a matching record or raise KeyError is no record is found.
If the record name is a full name we will first check for a record matching the full name.
If no such record is found any record matching the last part of the full name (without the na... | [
"Will",
"return",
"a",
"matching",
"record",
"or",
"raise",
"KeyError",
"is",
"no",
"record",
"is",
"found",
"."
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L152-L164 | [
"def",
"get",
"(",
"self",
",",
"record_name",
")",
":",
"if",
"record_name",
"in",
"self",
".",
"_schema_map",
":",
"return",
"self",
".",
"_schema_map",
"[",
"record_name",
"]",
"else",
":",
"last_name",
"=",
"record_name",
".",
"split",
"(",
"'.'",
")... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | Field.repr_vars | Return a dictionary the field definition
Should contain all fields that are required for the definition of this field in a pyschema class | pyschema/core.py | def repr_vars(self):
"""Return a dictionary the field definition
Should contain all fields that are required for the definition of this field in a pyschema class"""
d = OrderedDict()
d["nullable"] = repr(self.nullable)
d["default"] = repr(self.default)
if self.descriptio... | def repr_vars(self):
"""Return a dictionary the field definition
Should contain all fields that are required for the definition of this field in a pyschema class"""
d = OrderedDict()
d["nullable"] = repr(self.nullable)
d["default"] = repr(self.default)
if self.descriptio... | [
"Return",
"a",
"dictionary",
"the",
"field",
"definition"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L243-L252 | [
"def",
"repr_vars",
"(",
"self",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"d",
"[",
"\"nullable\"",
"]",
"=",
"repr",
"(",
"self",
".",
"nullable",
")",
"d",
"[",
"\"default\"",
"]",
"=",
"repr",
"(",
"self",
".",
"default",
")",
"if",
"self",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | Field.mixin | Decorator for mixing in additional functionality into field type
Example:
>>> @Integer.mixin
... class IntegerPostgresExtensions:
... postgres_type = 'INT'
...
... def postgres_dump(self, obj):
... self.dump(obj) + "::integer"
Is roughly... | pyschema/core.py | def mixin(cls, mixin_cls):
"""Decorator for mixing in additional functionality into field type
Example:
>>> @Integer.mixin
... class IntegerPostgresExtensions:
... postgres_type = 'INT'
...
... def postgres_dump(self, obj):
... self.dump(... | def mixin(cls, mixin_cls):
"""Decorator for mixing in additional functionality into field type
Example:
>>> @Integer.mixin
... class IntegerPostgresExtensions:
... postgres_type = 'INT'
...
... def postgres_dump(self, obj):
... self.dump(... | [
"Decorator",
"for",
"mixing",
"in",
"additional",
"functionality",
"into",
"field",
"type"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L272-L306 | [
"def",
"mixin",
"(",
"cls",
",",
"mixin_cls",
")",
":",
"for",
"item_name",
"in",
"dir",
"(",
"mixin_cls",
")",
":",
"if",
"item_name",
".",
"startswith",
"(",
"\"__\"",
")",
":",
"# don't copy magic properties",
"continue",
"item",
"=",
"getattr",
"(",
"m... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | PySchema.from_class | Create proper PySchema class from cls
Any methods and attributes will be transferred to the
new object | pyschema/core.py | def from_class(metacls, cls, auto_store=True):
"""Create proper PySchema class from cls
Any methods and attributes will be transferred to the
new object
"""
if auto_store:
def wrap(cls):
return cls
else:
wrap = no_auto_store()
... | def from_class(metacls, cls, auto_store=True):
"""Create proper PySchema class from cls
Any methods and attributes will be transferred to the
new object
"""
if auto_store:
def wrap(cls):
return cls
else:
wrap = no_auto_store()
... | [
"Create",
"proper",
"PySchema",
"class",
"from",
"cls"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/core.py#L388-L405 | [
"def",
"from_class",
"(",
"metacls",
",",
"cls",
",",
"auto_store",
"=",
"True",
")",
":",
"if",
"auto_store",
":",
"def",
"wrap",
"(",
"cls",
")",
":",
"return",
"cls",
"else",
":",
"wrap",
"=",
"no_auto_store",
"(",
")",
"return",
"wrap",
"(",
"met... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | get_schema_dict | Return a python dict representing the jsonschema of a record
Any references to sub-schemas will be URI fragments that won't be
resolvable without a root schema, available from get_root_schema_dict. | pyschema_extensions/jsonschema.py | def get_schema_dict(record, state=None):
"""Return a python dict representing the jsonschema of a record
Any references to sub-schemas will be URI fragments that won't be
resolvable without a root schema, available from get_root_schema_dict.
"""
state = state or SchemaGeneratorState()
schema = ... | def get_schema_dict(record, state=None):
"""Return a python dict representing the jsonschema of a record
Any references to sub-schemas will be URI fragments that won't be
resolvable without a root schema, available from get_root_schema_dict.
"""
state = state or SchemaGeneratorState()
schema = ... | [
"Return",
"a",
"python",
"dict",
"representing",
"the",
"jsonschema",
"of",
"a",
"record"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema_extensions/jsonschema.py#L116-L137 | [
"def",
"get_schema_dict",
"(",
"record",
",",
"state",
"=",
"None",
")",
":",
"state",
"=",
"state",
"or",
"SchemaGeneratorState",
"(",
")",
"schema",
"=",
"OrderedDict",
"(",
"[",
"(",
"'type'",
",",
"'object'",
")",
",",
"(",
"'id'",
",",
"record",
"... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | get_root_schema_dict | Return a root jsonschema for a given record
A root schema includes the $schema attribute and all sub-record
schemas and definitions. | pyschema_extensions/jsonschema.py | def get_root_schema_dict(record):
"""Return a root jsonschema for a given record
A root schema includes the $schema attribute and all sub-record
schemas and definitions.
"""
state = SchemaGeneratorState()
schema = get_schema_dict(record, state)
del state.record_schemas[record._schema_name]
... | def get_root_schema_dict(record):
"""Return a root jsonschema for a given record
A root schema includes the $schema attribute and all sub-record
schemas and definitions.
"""
state = SchemaGeneratorState()
schema = get_schema_dict(record, state)
del state.record_schemas[record._schema_name]
... | [
"Return",
"a",
"root",
"jsonschema",
"for",
"a",
"given",
"record"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema_extensions/jsonschema.py#L140-L153 | [
"def",
"get_root_schema_dict",
"(",
"record",
")",
":",
"state",
"=",
"SchemaGeneratorState",
"(",
")",
"schema",
"=",
"get_schema_dict",
"(",
"record",
",",
"state",
")",
"del",
"state",
".",
"record_schemas",
"[",
"record",
".",
"_schema_name",
"]",
"if",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | from_json_compatible | Load from json-encodable | pyschema_extensions/avro.py | def from_json_compatible(schema, dct):
"Load from json-encodable"
kwargs = {}
for key in dct:
field_type = schema._fields.get(key)
if field_type is None:
warnings.warn("Unexpected field encountered in line for record %s: %r" % (schema.__name__, key))
continue
... | def from_json_compatible(schema, dct):
"Load from json-encodable"
kwargs = {}
for key in dct:
field_type = schema._fields.get(key)
if field_type is None:
warnings.warn("Unexpected field encountered in line for record %s: %r" % (schema.__name__, key))
continue
... | [
"Load",
"from",
"json",
"-",
"encodable"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema_extensions/avro.py#L310-L321 | [
"def",
"from_json_compatible",
"(",
"schema",
",",
"dct",
")",
":",
"kwargs",
"=",
"{",
"}",
"for",
"key",
"in",
"dct",
":",
"field_type",
"=",
"schema",
".",
"_fields",
".",
"get",
"(",
"key",
")",
"if",
"field_type",
"is",
"None",
":",
"warnings",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | mr_reader | Converts a file object with json serialised pyschema records
to a stream of pyschema objects
Can be used as job.reader in luigi.hadoop.JobTask | pyschema_extensions/luigi.py | def mr_reader(job, input_stream, loads=core.loads):
""" Converts a file object with json serialised pyschema records
to a stream of pyschema objects
Can be used as job.reader in luigi.hadoop.JobTask
"""
for line in input_stream:
yield loads(line), | def mr_reader(job, input_stream, loads=core.loads):
""" Converts a file object with json serialised pyschema records
to a stream of pyschema objects
Can be used as job.reader in luigi.hadoop.JobTask
"""
for line in input_stream:
yield loads(line), | [
"Converts",
"a",
"file",
"object",
"with",
"json",
"serialised",
"pyschema",
"records",
"to",
"a",
"stream",
"of",
"pyschema",
"objects"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema_extensions/luigi.py#L21-L28 | [
"def",
"mr_reader",
"(",
"job",
",",
"input_stream",
",",
"loads",
"=",
"core",
".",
"loads",
")",
":",
"for",
"line",
"in",
"input_stream",
":",
"yield",
"loads",
"(",
"line",
")",
","
] | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | mr_writer | Writes a stream of json serialised pyschema Records to a file object
Can be used as job.writer in luigi.hadoop.JobTask | pyschema_extensions/luigi.py | def mr_writer(job, outputs, output_stream,
stderr=sys.stderr, dumps=core.dumps):
""" Writes a stream of json serialised pyschema Records to a file object
Can be used as job.writer in luigi.hadoop.JobTask
"""
for output in outputs:
try:
print >> output_stream, dumps(out... | def mr_writer(job, outputs, output_stream,
stderr=sys.stderr, dumps=core.dumps):
""" Writes a stream of json serialised pyschema Records to a file object
Can be used as job.writer in luigi.hadoop.JobTask
"""
for output in outputs:
try:
print >> output_stream, dumps(out... | [
"Writes",
"a",
"stream",
"of",
"json",
"serialised",
"pyschema",
"Records",
"to",
"a",
"file",
"object"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema_extensions/luigi.py#L31-L42 | [
"def",
"mr_writer",
"(",
"job",
",",
"outputs",
",",
"output_stream",
",",
"stderr",
"=",
"sys",
".",
"stderr",
",",
"dumps",
"=",
"core",
".",
"dumps",
")",
":",
"for",
"output",
"in",
"outputs",
":",
"try",
":",
"print",
">>",
"output_stream",
",",
... | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | ordereddict_push_front | Set a value at the front of an OrderedDict
The original dict isn't modified, instead a copy is returned | pyschema/types.py | def ordereddict_push_front(dct, key, value):
"""Set a value at the front of an OrderedDict
The original dict isn't modified, instead a copy is returned
"""
d = OrderedDict()
d[key] = value
d.update(dct)
return d | def ordereddict_push_front(dct, key, value):
"""Set a value at the front of an OrderedDict
The original dict isn't modified, instead a copy is returned
"""
d = OrderedDict()
d[key] = value
d.update(dct)
return d | [
"Set",
"a",
"value",
"at",
"the",
"front",
"of",
"an",
"OrderedDict"
] | spotify/pyschema | python | https://github.com/spotify/pyschema/blob/7e6c3934150bcb040c628d74ace6caf5fcf867df/pyschema/types.py#L26-L34 | [
"def",
"ordereddict_push_front",
"(",
"dct",
",",
"key",
",",
"value",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"d",
"[",
"key",
"]",
"=",
"value",
"d",
".",
"update",
"(",
"dct",
")",
"return",
"d"
] | 7e6c3934150bcb040c628d74ace6caf5fcf867df |
test | gen_filter | Generates a single filter expression for ``filter[]``. | src/manageiq_client/filters.py | def gen_filter(name, op, value, is_or=False):
"""Generates a single filter expression for ``filter[]``."""
if op not in OPERATORS:
raise ValueError('Unknown operator {}'.format(op))
result = u'{} {} {}'.format(name, op, escape_filter(value))
if is_or:
result = u'or ' + result
return ... | def gen_filter(name, op, value, is_or=False):
"""Generates a single filter expression for ``filter[]``."""
if op not in OPERATORS:
raise ValueError('Unknown operator {}'.format(op))
result = u'{} {} {}'.format(name, op, escape_filter(value))
if is_or:
result = u'or ' + result
return ... | [
"Generates",
"a",
"single",
"filter",
"expression",
"for",
"filter",
"[]",
"."
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/filters.py#L7-L14 | [
"def",
"gen_filter",
"(",
"name",
",",
"op",
",",
"value",
",",
"is_or",
"=",
"False",
")",
":",
"if",
"op",
"not",
"in",
"OPERATORS",
":",
"raise",
"ValueError",
"(",
"'Unknown operator {}'",
".",
"format",
"(",
"op",
")",
")",
"result",
"=",
"u'{} {}... | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | Q.from_dict | Creates a query (AND and =) from a dictionary. | src/manageiq_client/filters.py | def from_dict(cls, d):
"""Creates a query (AND and =) from a dictionary."""
if not d:
raise ValueError('Empty dictionary!')
items = list(d.items())
key, value = items.pop(0)
q = cls(key, u'=', value)
for key, value in items:
q = q & cls(key, u'=', ... | def from_dict(cls, d):
"""Creates a query (AND and =) from a dictionary."""
if not d:
raise ValueError('Empty dictionary!')
items = list(d.items())
key, value = items.pop(0)
q = cls(key, u'=', value)
for key, value in items:
q = q & cls(key, u'=', ... | [
"Creates",
"a",
"query",
"(",
"AND",
"and",
"=",
")",
"from",
"a",
"dictionary",
"."
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/filters.py#L37-L46 | [
"def",
"from_dict",
"(",
"cls",
",",
"d",
")",
":",
"if",
"not",
"d",
":",
"raise",
"ValueError",
"(",
"'Empty dictionary!'",
")",
"items",
"=",
"list",
"(",
"d",
".",
"items",
"(",
")",
")",
"key",
",",
"value",
"=",
"items",
".",
"pop",
"(",
"0... | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | Collection.query_string | Specify query string to use with the collection.
Returns: :py:class:`SearchResult` | src/manageiq_client/api.py | def query_string(self, **params):
"""Specify query string to use with the collection.
Returns: :py:class:`SearchResult`
"""
return SearchResult(self, self._api.get(self._href, **params)) | def query_string(self, **params):
"""Specify query string to use with the collection.
Returns: :py:class:`SearchResult`
"""
return SearchResult(self, self._api.get(self._href, **params)) | [
"Specify",
"query",
"string",
"to",
"use",
"with",
"the",
"collection",
"."
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/api.py#L332-L337 | [
"def",
"query_string",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"return",
"SearchResult",
"(",
"self",
",",
"self",
".",
"_api",
".",
"get",
"(",
"self",
".",
"_href",
",",
"*",
"*",
"params",
")",
")"
] | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | Collection.raw_filter | Sends all filters to the API.
No fancy, just a wrapper. Any advanced functionality shall be implemented as another method.
Args:
filters: List of filters (strings)
Returns: :py:class:`SearchResult` | src/manageiq_client/api.py | def raw_filter(self, filters):
"""Sends all filters to the API.
No fancy, just a wrapper. Any advanced functionality shall be implemented as another method.
Args:
filters: List of filters (strings)
Returns: :py:class:`SearchResult`
"""
return SearchResult(s... | def raw_filter(self, filters):
"""Sends all filters to the API.
No fancy, just a wrapper. Any advanced functionality shall be implemented as another method.
Args:
filters: List of filters (strings)
Returns: :py:class:`SearchResult`
"""
return SearchResult(s... | [
"Sends",
"all",
"filters",
"to",
"the",
"API",
"."
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/api.py#L339-L349 | [
"def",
"raw_filter",
"(",
"self",
",",
"filters",
")",
":",
"return",
"SearchResult",
"(",
"self",
",",
"self",
".",
"_api",
".",
"get",
"(",
"self",
".",
"_href",
",",
"*",
"*",
"{",
"\"filter[]\"",
":",
"filters",
"}",
")",
")"
] | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | Collection.all_include_attributes | Returns all entities present in the collection with ``attributes`` included. | src/manageiq_client/api.py | def all_include_attributes(self, attributes):
"""Returns all entities present in the collection with ``attributes`` included."""
self.reload(expand=True, attributes=attributes)
entities = [Entity(self, r, attributes=attributes) for r in self._resources]
self.reload()
return entit... | def all_include_attributes(self, attributes):
"""Returns all entities present in the collection with ``attributes`` included."""
self.reload(expand=True, attributes=attributes)
entities = [Entity(self, r, attributes=attributes) for r in self._resources]
self.reload()
return entit... | [
"Returns",
"all",
"entities",
"present",
"in",
"the",
"collection",
"with",
"attributes",
"included",
"."
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/api.py#L393-L398 | [
"def",
"all_include_attributes",
"(",
"self",
",",
"attributes",
")",
":",
"self",
".",
"reload",
"(",
"expand",
"=",
"True",
",",
"attributes",
"=",
"attributes",
")",
"entities",
"=",
"[",
"Entity",
"(",
"self",
",",
"r",
",",
"attributes",
"=",
"attri... | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | Action._get_entity_from_href | Returns entity in correct collection.
If the "href" value in result doesn't match the current collection,
try to find the collection that the "href" refers to. | src/manageiq_client/api.py | def _get_entity_from_href(self, result):
"""Returns entity in correct collection.
If the "href" value in result doesn't match the current collection,
try to find the collection that the "href" refers to.
"""
href_result = result['href']
if self.collection._href.startswi... | def _get_entity_from_href(self, result):
"""Returns entity in correct collection.
If the "href" value in result doesn't match the current collection,
try to find the collection that the "href" refers to.
"""
href_result = result['href']
if self.collection._href.startswi... | [
"Returns",
"entity",
"in",
"correct",
"collection",
"."
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/api.py#L703-L724 | [
"def",
"_get_entity_from_href",
"(",
"self",
",",
"result",
")",
":",
"href_result",
"=",
"result",
"[",
"'href'",
"]",
"if",
"self",
".",
"collection",
".",
"_href",
".",
"startswith",
"(",
"href_result",
")",
":",
"return",
"Entity",
"(",
"self",
".",
... | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | give_another_quote | When you pass a quote character, returns you an another one if possible | src/manageiq_client/utils.py | def give_another_quote(q):
"""When you pass a quote character, returns you an another one if possible"""
for qc in QUOTES:
if qc != q:
return qc
else:
raise ValueError(u'Could not find a different quote for {}'.format(q)) | def give_another_quote(q):
"""When you pass a quote character, returns you an another one if possible"""
for qc in QUOTES:
if qc != q:
return qc
else:
raise ValueError(u'Could not find a different quote for {}'.format(q)) | [
"When",
"you",
"pass",
"a",
"quote",
"character",
"returns",
"you",
"an",
"another",
"one",
"if",
"possible"
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/utils.py#L7-L13 | [
"def",
"give_another_quote",
"(",
"q",
")",
":",
"for",
"qc",
"in",
"QUOTES",
":",
"if",
"qc",
"!=",
"q",
":",
"return",
"qc",
"else",
":",
"raise",
"ValueError",
"(",
"u'Could not find a different quote for {}'",
".",
"format",
"(",
"q",
")",
")"
] | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | escape_filter | Tries to escape the values that are passed to filter as correctly as possible.
No standard way is followed, but at least it is simple. | src/manageiq_client/utils.py | def escape_filter(o):
"""Tries to escape the values that are passed to filter as correctly as possible.
No standard way is followed, but at least it is simple.
"""
if o is None:
return u'NULL'
if isinstance(o, int):
return str(o)
if not isinstance(o, six.string_types):
r... | def escape_filter(o):
"""Tries to escape the values that are passed to filter as correctly as possible.
No standard way is followed, but at least it is simple.
"""
if o is None:
return u'NULL'
if isinstance(o, int):
return str(o)
if not isinstance(o, six.string_types):
r... | [
"Tries",
"to",
"escape",
"the",
"values",
"that",
"are",
"passed",
"to",
"filter",
"as",
"correctly",
"as",
"possible",
"."
] | ManageIQ/manageiq-api-client-python | python | https://github.com/ManageIQ/manageiq-api-client-python/blob/e0c8884929e45766c2835bc7dcf4e78b0794248f/src/manageiq_client/utils.py#L16-L66 | [
"def",
"escape_filter",
"(",
"o",
")",
":",
"if",
"o",
"is",
"None",
":",
"return",
"u'NULL'",
"if",
"isinstance",
"(",
"o",
",",
"int",
")",
":",
"return",
"str",
"(",
"o",
")",
"if",
"not",
"isinstance",
"(",
"o",
",",
"six",
".",
"string_types",... | e0c8884929e45766c2835bc7dcf4e78b0794248f |
test | makePlot | Make the plot with parallax performance predictions.
:argument args: command line arguments | examples/plotParallaxErrorsSkyAvg.py | def makePlot(args):
"""
Make the plot with parallax performance predictions.
:argument args: command line arguments
"""
gmag=np.linspace(5.7,20.0,101)
vminiB1V=vminiFromSpt('B1V')
vminiG2V=vminiFromSpt('G2V')
vminiM6V=vminiFromSpt('M6V')
vmagB1V=gmag-gminvFromVmini(vminiB1V)
vmagG2V=gmag-gminvF... | def makePlot(args):
"""
Make the plot with parallax performance predictions.
:argument args: command line arguments
"""
gmag=np.linspace(5.7,20.0,101)
vminiB1V=vminiFromSpt('B1V')
vminiG2V=vminiFromSpt('G2V')
vminiM6V=vminiFromSpt('M6V')
vmagB1V=gmag-gminvFromVmini(vminiB1V)
vmagG2V=gmag-gminvF... | [
"Make",
"the",
"plot",
"with",
"parallax",
"performance",
"predictions",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/plotParallaxErrorsSkyAvg.py#L32-L116 | [
"def",
"makePlot",
"(",
"args",
")",
":",
"gmag",
"=",
"np",
".",
"linspace",
"(",
"5.7",
",",
"20.0",
",",
"101",
")",
"vminiB1V",
"=",
"vminiFromSpt",
"(",
"'B1V'",
")",
"vminiG2V",
"=",
"vminiFromSpt",
"(",
"'G2V'",
")",
"vminiM6V",
"=",
"vminiFromS... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | plotBrightLimitInV | Plot the bright limit of Gaia in V as a function of (V-I).
Parameters
----------
gBright - The bright limit of Gaia in G | examples/brightLimitInVband.py | def plotBrightLimitInV(gBright, pdf=False, png=False):
"""
Plot the bright limit of Gaia in V as a function of (V-I).
Parameters
----------
gBright - The bright limit of Gaia in G
"""
vmini=np.linspace(0.0,6.0,1001)
gminv=gminvFromVmini(vmini)
vBright=gBright-gminv
fig=plt.figure(figsize=(10,6.5)... | def plotBrightLimitInV(gBright, pdf=False, png=False):
"""
Plot the bright limit of Gaia in V as a function of (V-I).
Parameters
----------
gBright - The bright limit of Gaia in G
"""
vmini=np.linspace(0.0,6.0,1001)
gminv=gminvFromVmini(vmini)
vBright=gBright-gminv
fig=plt.figure(figsize=(10,6.5)... | [
"Plot",
"the",
"bright",
"limit",
"of",
"Gaia",
"in",
"V",
"as",
"a",
"function",
"of",
"(",
"V",
"-",
"I",
")",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/brightLimitInVband.py#L26-L53 | [
"def",
"plotBrightLimitInV",
"(",
"gBright",
",",
"pdf",
"=",
"False",
",",
"png",
"=",
"False",
")",
":",
"vmini",
"=",
"np",
".",
"linspace",
"(",
"0.0",
",",
"6.0",
",",
"1001",
")",
"gminv",
"=",
"gminvFromVmini",
"(",
"vmini",
")",
"vBright",
"=... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | sphericalToCartesian | Convert spherical to Cartesian coordinates. The input can be scalars or 1-dimensional numpy arrays.
Note that the angle coordinates follow the astronomical convention of using elevation (declination,
latitude) rather than its complement (pi/2-elevation), where the latter is commonly used in the
mathematical treat... | pygaia/astrometry/vectorastrometry.py | def sphericalToCartesian(r, phi, theta):
"""
Convert spherical to Cartesian coordinates. The input can be scalars or 1-dimensional numpy arrays.
Note that the angle coordinates follow the astronomical convention of using elevation (declination,
latitude) rather than its complement (pi/2-elevation), where the la... | def sphericalToCartesian(r, phi, theta):
"""
Convert spherical to Cartesian coordinates. The input can be scalars or 1-dimensional numpy arrays.
Note that the angle coordinates follow the astronomical convention of using elevation (declination,
latitude) rather than its complement (pi/2-elevation), where the la... | [
"Convert",
"spherical",
"to",
"Cartesian",
"coordinates",
".",
"The",
"input",
"can",
"be",
"scalars",
"or",
"1",
"-",
"dimensional",
"numpy",
"arrays",
".",
"Note",
"that",
"the",
"angle",
"coordinates",
"follow",
"the",
"astronomical",
"convention",
"of",
"u... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/astrometry/vectorastrometry.py#L19-L42 | [
"def",
"sphericalToCartesian",
"(",
"r",
",",
"phi",
",",
"theta",
")",
":",
"ctheta",
"=",
"cos",
"(",
"theta",
")",
"x",
"=",
"r",
"*",
"cos",
"(",
"phi",
")",
"*",
"ctheta",
"y",
"=",
"r",
"*",
"sin",
"(",
"phi",
")",
"*",
"ctheta",
"z",
"... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | cartesianToSpherical | Convert Cartesian to spherical coordinates. The input can be scalars or 1-dimensional numpy arrays.
Note that the angle coordinates follow the astronomical convention of using elevation (declination,
latitude) rather than its complement (pi/2-elevation), which is commonly used in the mathematical
treatment of sph... | pygaia/astrometry/vectorastrometry.py | def cartesianToSpherical(x, y, z):
"""
Convert Cartesian to spherical coordinates. The input can be scalars or 1-dimensional numpy arrays.
Note that the angle coordinates follow the astronomical convention of using elevation (declination,
latitude) rather than its complement (pi/2-elevation), which is commonly ... | def cartesianToSpherical(x, y, z):
"""
Convert Cartesian to spherical coordinates. The input can be scalars or 1-dimensional numpy arrays.
Note that the angle coordinates follow the astronomical convention of using elevation (declination,
latitude) rather than its complement (pi/2-elevation), which is commonly ... | [
"Convert",
"Cartesian",
"to",
"spherical",
"coordinates",
".",
"The",
"input",
"can",
"be",
"scalars",
"or",
"1",
"-",
"dimensional",
"numpy",
"arrays",
".",
"Note",
"that",
"the",
"angle",
"coordinates",
"follow",
"the",
"astronomical",
"convention",
"of",
"u... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/astrometry/vectorastrometry.py#L44-L71 | [
"def",
"cartesianToSpherical",
"(",
"x",
",",
"y",
",",
"z",
")",
":",
"rCylSq",
"=",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"r",
"=",
"sqrt",
"(",
"rCylSq",
"+",
"z",
"*",
"z",
")",
"if",
"any",
"(",
"r",
"==",
"0.0",
")",
":",
"raise",
"Excep... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | normalTriad | Calculate the so-called normal triad [p, q, r] which is associated with a spherical coordinate system .
The three vectors are:
p - The unit tangent vector in the direction of increasing longitudinal angle phi.
q - The unit tangent vector in the direction of increasing latitudinal angle theta.
r - The unit vect... | pygaia/astrometry/vectorastrometry.py | def normalTriad(phi, theta):
"""
Calculate the so-called normal triad [p, q, r] which is associated with a spherical coordinate system .
The three vectors are:
p - The unit tangent vector in the direction of increasing longitudinal angle phi.
q - The unit tangent vector in the direction of increasing latitud... | def normalTriad(phi, theta):
"""
Calculate the so-called normal triad [p, q, r] which is associated with a spherical coordinate system .
The three vectors are:
p - The unit tangent vector in the direction of increasing longitudinal angle phi.
q - The unit tangent vector in the direction of increasing latitud... | [
"Calculate",
"the",
"so",
"-",
"called",
"normal",
"triad",
"[",
"p",
"q",
"r",
"]",
"which",
"is",
"associated",
"with",
"a",
"spherical",
"coordinate",
"system",
".",
"The",
"three",
"vectors",
"are",
":"
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/astrometry/vectorastrometry.py#L73-L100 | [
"def",
"normalTriad",
"(",
"phi",
",",
"theta",
")",
":",
"sphi",
"=",
"sin",
"(",
"phi",
")",
"stheta",
"=",
"sin",
"(",
"theta",
")",
"cphi",
"=",
"cos",
"(",
"phi",
")",
"ctheta",
"=",
"cos",
"(",
"theta",
")",
"p",
"=",
"array",
"(",
"[",
... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | elementaryRotationMatrix | Construct an elementary rotation matrix describing a rotation around the x, y, or z-axis.
Parameters
----------
axis - Axis around which to rotate ("x", "y", or "z")
rotationAngle - the rotation angle in radians
Returns
-------
The rotation matrix
Example usage
-------------
rotmat = ... | pygaia/astrometry/vectorastrometry.py | def elementaryRotationMatrix(axis, rotationAngle):
"""
Construct an elementary rotation matrix describing a rotation around the x, y, or z-axis.
Parameters
----------
axis - Axis around which to rotate ("x", "y", or "z")
rotationAngle - the rotation angle in radians
Returns
-------
The ro... | def elementaryRotationMatrix(axis, rotationAngle):
"""
Construct an elementary rotation matrix describing a rotation around the x, y, or z-axis.
Parameters
----------
axis - Axis around which to rotate ("x", "y", or "z")
rotationAngle - the rotation angle in radians
Returns
-------
The ro... | [
"Construct",
"an",
"elementary",
"rotation",
"matrix",
"describing",
"a",
"rotation",
"around",
"the",
"x",
"y",
"or",
"z",
"-",
"axis",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/astrometry/vectorastrometry.py#L102-L132 | [
"def",
"elementaryRotationMatrix",
"(",
"axis",
",",
"rotationAngle",
")",
":",
"if",
"(",
"axis",
"==",
"\"x\"",
"or",
"axis",
"==",
"\"X\"",
")",
":",
"return",
"array",
"(",
"[",
"[",
"1.0",
",",
"0.0",
",",
"0.0",
"]",
",",
"[",
"0.0",
",",
"co... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | phaseSpaceToAstrometry | From the given phase space coordinates calculate the astrometric observables, including the radial
velocity, which here is seen as the sixth astrometric parameter. The phase space coordinates are
assumed to represent barycentric (i.e. centred on the Sun) positions and velocities.
This function has no mechanism t... | pygaia/astrometry/vectorastrometry.py | def phaseSpaceToAstrometry(x, y, z, vx, vy, vz):
"""
From the given phase space coordinates calculate the astrometric observables, including the radial
velocity, which here is seen as the sixth astrometric parameter. The phase space coordinates are
assumed to represent barycentric (i.e. centred on the Sun) posi... | def phaseSpaceToAstrometry(x, y, z, vx, vy, vz):
"""
From the given phase space coordinates calculate the astrometric observables, including the radial
velocity, which here is seen as the sixth astrometric parameter. The phase space coordinates are
assumed to represent barycentric (i.e. centred on the Sun) posi... | [
"From",
"the",
"given",
"phase",
"space",
"coordinates",
"calculate",
"the",
"astrometric",
"observables",
"including",
"the",
"radial",
"velocity",
"which",
"here",
"is",
"seen",
"as",
"the",
"sixth",
"astrometric",
"parameter",
".",
"The",
"phase",
"space",
"c... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/astrometry/vectorastrometry.py#L134-L186 | [
"def",
"phaseSpaceToAstrometry",
"(",
"x",
",",
"y",
",",
"z",
",",
"vx",
",",
"vy",
",",
"vz",
")",
":",
"u",
",",
"phi",
",",
"theta",
"=",
"cartesianToSpherical",
"(",
"x",
",",
"y",
",",
"z",
")",
"parallax",
"=",
"_auMasParsec",
"/",
"u",
"p... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | astrometryToPhaseSpace | From the input astrometric parameters calculate the phase space coordinates. The output phase space
coordinates represent barycentric (i.e. centred on the Sun) positions and velocities.
This function has no mechanism to deal with units. The code is set up such that for input astrometry
with parallaxes and proper... | pygaia/astrometry/vectorastrometry.py | def astrometryToPhaseSpace(phi, theta, parallax, muphistar, mutheta, vrad):
"""
From the input astrometric parameters calculate the phase space coordinates. The output phase space
coordinates represent barycentric (i.e. centred on the Sun) positions and velocities.
This function has no mechanism to deal with u... | def astrometryToPhaseSpace(phi, theta, parallax, muphistar, mutheta, vrad):
"""
From the input astrometric parameters calculate the phase space coordinates. The output phase space
coordinates represent barycentric (i.e. centred on the Sun) positions and velocities.
This function has no mechanism to deal with u... | [
"From",
"the",
"input",
"astrometric",
"parameters",
"calculate",
"the",
"phase",
"space",
"coordinates",
".",
"The",
"output",
"phase",
"space",
"coordinates",
"represent",
"barycentric",
"(",
"i",
".",
"e",
".",
"centred",
"on",
"the",
"Sun",
")",
"positions... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/astrometry/vectorastrometry.py#L188-L248 | [
"def",
"astrometryToPhaseSpace",
"(",
"phi",
",",
"theta",
",",
"parallax",
",",
"muphistar",
",",
"mutheta",
",",
"vrad",
")",
":",
"if",
"any",
"(",
"parallax",
"<=",
"0.0",
")",
":",
"raise",
"Exception",
"(",
"\"One or more of the input parallaxes is non-pos... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | makePlot | Make the plot with proper motion performance predictions. The predictions are for the TOTAL proper
motion under the assumption of equal components mu_alpha* and mu_delta.
:argument args: command line arguments | examples/plotProperMotionErrorsSkyAvg.py | def makePlot(args):
"""
Make the plot with proper motion performance predictions. The predictions are for the TOTAL proper
motion under the assumption of equal components mu_alpha* and mu_delta.
:argument args: command line arguments
"""
gmag=np.linspace(5.7,20.0,101)
vminiB1V=vminiFromSpt('B1V')
vmin... | def makePlot(args):
"""
Make the plot with proper motion performance predictions. The predictions are for the TOTAL proper
motion under the assumption of equal components mu_alpha* and mu_delta.
:argument args: command line arguments
"""
gmag=np.linspace(5.7,20.0,101)
vminiB1V=vminiFromSpt('B1V')
vmin... | [
"Make",
"the",
"plot",
"with",
"proper",
"motion",
"performance",
"predictions",
".",
"The",
"predictions",
"are",
"for",
"the",
"TOTAL",
"proper",
"motion",
"under",
"the",
"assumption",
"of",
"equal",
"components",
"mu_alpha",
"*",
"and",
"mu_delta",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/plotProperMotionErrorsSkyAvg.py#L31-L125 | [
"def",
"makePlot",
"(",
"args",
")",
":",
"gmag",
"=",
"np",
".",
"linspace",
"(",
"5.7",
",",
"20.0",
",",
"101",
")",
"vminiB1V",
"=",
"vminiFromSpt",
"(",
"'B1V'",
")",
"vminiG2V",
"=",
"vminiFromSpt",
"(",
"'G2V'",
")",
"vminiM6V",
"=",
"vminiFromS... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | parseCommandLineArguments | Set up command line parsing. | examples/plotProperMotionErrorsSkyAvg.py | def parseCommandLineArguments():
"""
Set up command line parsing.
"""
parser = argparse.ArgumentParser(description="Plot predicted Gaia sky averaged proper motion errors as a function of V")
parser.add_argument("-p", action="store_true", dest="pdfOutput", help="Make PDF plot")
parser.add_argument("-b", acti... | def parseCommandLineArguments():
"""
Set up command line parsing.
"""
parser = argparse.ArgumentParser(description="Plot predicted Gaia sky averaged proper motion errors as a function of V")
parser.add_argument("-p", action="store_true", dest="pdfOutput", help="Make PDF plot")
parser.add_argument("-b", acti... | [
"Set",
"up",
"command",
"line",
"parsing",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/plotProperMotionErrorsSkyAvg.py#L127-L136 | [
"def",
"parseCommandLineArguments",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Plot predicted Gaia sky averaged proper motion errors as a function of V\"",
")",
"parser",
".",
"add_argument",
"(",
"\"-p\"",
",",
"action",
... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | enum | Create a new enumeration type.
Code is copyright (c) Gabriel Genellina, 2010, MIT License.
Parameters
----------
typename - Name of the enumerated type
field_names - Names of the fields of the enumerated type | pygaia/utils.py | def enum(typename, field_names):
"""
Create a new enumeration type.
Code is copyright (c) Gabriel Genellina, 2010, MIT License.
Parameters
----------
typename - Name of the enumerated type
field_names - Names of the fields of the enumerated type
"""
if isinstance(field_names, s... | def enum(typename, field_names):
"""
Create a new enumeration type.
Code is copyright (c) Gabriel Genellina, 2010, MIT License.
Parameters
----------
typename - Name of the enumerated type
field_names - Names of the fields of the enumerated type
"""
if isinstance(field_names, s... | [
"Create",
"a",
"new",
"enumeration",
"type",
".",
"Code",
"is",
"copyright",
"(",
"c",
")",
"Gabriel",
"Genellina",
"2010",
"MIT",
"License",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/utils.py#L7-L23 | [
"def",
"enum",
"(",
"typename",
",",
"field_names",
")",
":",
"if",
"isinstance",
"(",
"field_names",
",",
"str",
")",
":",
"field_names",
"=",
"field_names",
".",
"replace",
"(",
"','",
",",
"' '",
")",
".",
"split",
"(",
")",
"d",
"=",
"dict",
"(",... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | construct_covariance_matrix | Take the astrometric parameter standard uncertainties and the uncertainty correlations as quoted in
the Gaia catalogue and construct the covariance matrix.
Parameters
----------
cvec : array_like
Array of shape (15,) (1 source) or (n,15) (n sources) for the astrometric parameter standard
... | pygaia/utils.py | def construct_covariance_matrix(cvec, parallax, radial_velocity, radial_velocity_error):
"""
Take the astrometric parameter standard uncertainties and the uncertainty correlations as quoted in
the Gaia catalogue and construct the covariance matrix.
Parameters
----------
cvec : array_like
... | def construct_covariance_matrix(cvec, parallax, radial_velocity, radial_velocity_error):
"""
Take the astrometric parameter standard uncertainties and the uncertainty correlations as quoted in
the Gaia catalogue and construct the covariance matrix.
Parameters
----------
cvec : array_like
... | [
"Take",
"the",
"astrometric",
"parameter",
"standard",
"uncertainties",
"and",
"the",
"uncertainty",
"correlations",
"as",
"quoted",
"in",
"the",
"Gaia",
"catalogue",
"and",
"construct",
"the",
"covariance",
"matrix",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/utils.py#L57-L113 | [
"def",
"construct_covariance_matrix",
"(",
"cvec",
",",
"parallax",
",",
"radial_velocity",
",",
"radial_velocity_error",
")",
":",
"if",
"np",
".",
"ndim",
"(",
"cvec",
")",
"==",
"1",
":",
"cmat",
"=",
"np",
".",
"zeros",
"(",
"(",
"1",
",",
"6",
","... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | makePlot | Make a plot of a Mv vs (V-I) colour magnitude diagram containing lines of constant distance for stars
at G=20. This will give an idea of the reach of Gaia.
Parameters
----------
args - command line arguments | examples/plotDistanceLimitsInMvVmini.py | def makePlot(gmag, pdf=False, png=False, rvs=False):
"""
Make a plot of a Mv vs (V-I) colour magnitude diagram containing lines of constant distance for stars
at G=20. This will give an idea of the reach of Gaia.
Parameters
----------
args - command line arguments
"""
vmini = np.linspace(-0.5,4.0,100)... | def makePlot(gmag, pdf=False, png=False, rvs=False):
"""
Make a plot of a Mv vs (V-I) colour magnitude diagram containing lines of constant distance for stars
at G=20. This will give an idea of the reach of Gaia.
Parameters
----------
args - command line arguments
"""
vmini = np.linspace(-0.5,4.0,100)... | [
"Make",
"a",
"plot",
"of",
"a",
"Mv",
"vs",
"(",
"V",
"-",
"I",
")",
"colour",
"magnitude",
"diagram",
"containing",
"lines",
"of",
"constant",
"distance",
"for",
"stars",
"at",
"G",
"=",
"20",
".",
"This",
"will",
"give",
"an",
"idea",
"of",
"the",
... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/plotDistanceLimitsInMvVmini.py#L27-L67 | [
"def",
"makePlot",
"(",
"gmag",
",",
"pdf",
"=",
"False",
",",
"png",
"=",
"False",
",",
"rvs",
"=",
"False",
")",
":",
"vmini",
"=",
"np",
".",
"linspace",
"(",
"-",
"0.5",
",",
"4.0",
",",
"100",
")",
"if",
"(",
"rvs",
")",
":",
"gminv",
"=... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | vradErrorSkyAvg | Calculate radial velocity error from V and the spectral type. The value of the error is an average over
the sky.
Parameters
----------
vmag - Value of V-band magnitude.
spt - String representing the spectral type of the star.
Returns
-------
The radial velocity error in km/s. | pygaia/errors/spectroscopic.py | def vradErrorSkyAvg(vmag, spt):
"""
Calculate radial velocity error from V and the spectral type. The value of the error is an average over
the sky.
Parameters
----------
vmag - Value of V-band magnitude.
spt - String representing the spectral type of the star.
Returns
-------
The radial veloci... | def vradErrorSkyAvg(vmag, spt):
"""
Calculate radial velocity error from V and the spectral type. The value of the error is an average over
the sky.
Parameters
----------
vmag - Value of V-band magnitude.
spt - String representing the spectral type of the star.
Returns
-------
The radial veloci... | [
"Calculate",
"radial",
"velocity",
"error",
"from",
"V",
"and",
"the",
"spectral",
"type",
".",
"The",
"value",
"of",
"the",
"error",
"is",
"an",
"average",
"over",
"the",
"sky",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/errors/spectroscopic.py#L12-L28 | [
"def",
"vradErrorSkyAvg",
"(",
"vmag",
",",
"spt",
")",
":",
"return",
"_vradCalibrationFloor",
"+",
"_vradErrorBCoeff",
"[",
"spt",
"]",
"*",
"exp",
"(",
"_vradErrorACoeff",
"[",
"spt",
"]",
"*",
"(",
"vmag",
"-",
"_vradMagnitudeZeroPoint",
")",
")"
] | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | _orderGridlinePoints | This code takes care of ordering the points (x,y), calculated for a sky map parallel or merdian, such
that the drawing code can start at one end of the curve and end at the other (so no artifacts due to
connecting the disjoint ends occur).
Parameters
----------
x - Set of x coordinates
y - Set of y coordi... | pygaia/plot/sky.py | def _orderGridlinePoints(x, y):
"""
This code takes care of ordering the points (x,y), calculated for a sky map parallel or merdian, such
that the drawing code can start at one end of the curve and end at the other (so no artifacts due to
connecting the disjoint ends occur).
Parameters
----------
x - Se... | def _orderGridlinePoints(x, y):
"""
This code takes care of ordering the points (x,y), calculated for a sky map parallel or merdian, such
that the drawing code can start at one end of the curve and end at the other (so no artifacts due to
connecting the disjoint ends occur).
Parameters
----------
x - Se... | [
"This",
"code",
"takes",
"care",
"of",
"ordering",
"the",
"points",
"(",
"x",
"y",
")",
"calculated",
"for",
"a",
"sky",
"map",
"parallel",
"or",
"merdian",
"such",
"that",
"the",
"drawing",
"code",
"can",
"start",
"at",
"one",
"end",
"of",
"the",
"cur... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/plot/sky.py#L10-L31 | [
"def",
"_orderGridlinePoints",
"(",
"x",
",",
"y",
")",
":",
"xroll",
"=",
"roll",
"(",
"x",
",",
"1",
")",
"yroll",
"=",
"roll",
"(",
"y",
",",
"1",
")",
"distance",
"=",
"(",
"xroll",
"-",
"x",
")",
"**",
"2",
"+",
"(",
"yroll",
"-",
"y",
... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | plotCoordinateTransformationOnSky | Produce a sky-plot in a given coordinate system with the meridians and paralles for another
coordinate system overlayed. The coordinate systems are specified through the
pygaia.coordinates.Transformations enum. For example for Transformations.GAL2ECL the sky plot will be
in Ecliptic coordinates with the Gal... | pygaia/plot/sky.py | def plotCoordinateTransformationOnSky(transformation, outfile=None, myProjection='hammer',
noTitle=False, noLabels=False, returnPlotObject=False):
"""
Produce a sky-plot in a given coordinate system with the meridians and paralles for another
coordinate system overlayed. The coordinate systems are speci... | def plotCoordinateTransformationOnSky(transformation, outfile=None, myProjection='hammer',
noTitle=False, noLabels=False, returnPlotObject=False):
"""
Produce a sky-plot in a given coordinate system with the meridians and paralles for another
coordinate system overlayed. The coordinate systems are speci... | [
"Produce",
"a",
"sky",
"-",
"plot",
"in",
"a",
"given",
"coordinate",
"system",
"with",
"the",
"meridians",
"and",
"paralles",
"for",
"another",
"coordinate",
"system",
"overlayed",
".",
"The",
"coordinate",
"systems",
"are",
"specified",
"through",
"the",
"py... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/plot/sky.py#L33-L127 | [
"def",
"plotCoordinateTransformationOnSky",
"(",
"transformation",
",",
"outfile",
"=",
"None",
",",
"myProjection",
"=",
"'hammer'",
",",
"noTitle",
"=",
"False",
",",
"noLabels",
"=",
"False",
",",
"returnPlotObject",
"=",
"False",
")",
":",
"ct",
"=",
"Coor... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | calcParallaxError | Calculate the parallax error for the given input source magnitude and colour.
:argument args: command line arguments | examples/parallax_errors.py | def calcParallaxError(args):
"""
Calculate the parallax error for the given input source magnitude and colour.
:argument args: command line arguments
"""
gmag=float(args['gmag'])
vmini=float(args['vmini'])
sigmaPar=parallaxErrorSkyAvg(gmag, vmini)
gminv=gminvFromVmini(vmini)
print("G = {0}".format(gm... | def calcParallaxError(args):
"""
Calculate the parallax error for the given input source magnitude and colour.
:argument args: command line arguments
"""
gmag=float(args['gmag'])
vmini=float(args['vmini'])
sigmaPar=parallaxErrorSkyAvg(gmag, vmini)
gminv=gminvFromVmini(vmini)
print("G = {0}".format(gm... | [
"Calculate",
"the",
"parallax",
"error",
"for",
"the",
"given",
"input",
"source",
"magnitude",
"and",
"colour",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/parallax_errors.py#L17-L31 | [
"def",
"calcParallaxError",
"(",
"args",
")",
":",
"gmag",
"=",
"float",
"(",
"args",
"[",
"'gmag'",
"]",
")",
"vmini",
"=",
"float",
"(",
"args",
"[",
"'vmini'",
"]",
")",
"sigmaPar",
"=",
"parallaxErrorSkyAvg",
"(",
"gmag",
",",
"vmini",
")",
"gminv"... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | parseCommandLineArguments | Set up command line parsing. | examples/parallax_errors.py | def parseCommandLineArguments():
"""
Set up command line parsing.
"""
parser = argparse.ArgumentParser(description="Calculate parallax error for given G and (V-I)")
parser.add_argument("gmag", help="G-band magnitude of source", type=float)
parser.add_argument("vmini", help="(V-I) colour of source", type=flo... | def parseCommandLineArguments():
"""
Set up command line parsing.
"""
parser = argparse.ArgumentParser(description="Calculate parallax error for given G and (V-I)")
parser.add_argument("gmag", help="G-band magnitude of source", type=float)
parser.add_argument("vmini", help="(V-I) colour of source", type=flo... | [
"Set",
"up",
"command",
"line",
"parsing",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/parallax_errors.py#L33-L42 | [
"def",
"parseCommandLineArguments",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Calculate parallax error for given G and (V-I)\"",
")",
"parser",
".",
"add_argument",
"(",
"\"gmag\"",
",",
"help",
"=",
"\"G-band magnitude... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | gMagnitudeError | Calculate the single-field-of-view-transit photometric standard error in the G band as a function
of G. A 20% margin is included.
Parameters
----------
G - Value(s) of G-band magnitude.
Returns
-------
The G band photometric standard error in units of magnitude. | pygaia/errors/photometric.py | def gMagnitudeError(G):
"""
Calculate the single-field-of-view-transit photometric standard error in the G band as a function
of G. A 20% margin is included.
Parameters
----------
G - Value(s) of G-band magnitude.
Returns
-------
The G band photometric standard error in units of magnitude.
"... | def gMagnitudeError(G):
"""
Calculate the single-field-of-view-transit photometric standard error in the G band as a function
of G. A 20% margin is included.
Parameters
----------
G - Value(s) of G-band magnitude.
Returns
-------
The G band photometric standard error in units of magnitude.
"... | [
"Calculate",
"the",
"single",
"-",
"field",
"-",
"of",
"-",
"view",
"-",
"transit",
"photometric",
"standard",
"error",
"in",
"the",
"G",
"band",
"as",
"a",
"function",
"of",
"G",
".",
"A",
"20%",
"margin",
"is",
"included",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/errors/photometric.py#L20-L36 | [
"def",
"gMagnitudeError",
"(",
"G",
")",
":",
"z",
"=",
"calcZ",
"(",
"G",
")",
"return",
"1.0e-3",
"*",
"sqrt",
"(",
"0.04895",
"*",
"z",
"*",
"z",
"+",
"1.8633",
"*",
"z",
"+",
"0.0001985",
")",
"*",
"_scienceMargin"
] | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | gMagnitudeErrorEoM | Calculate the end of mission photometric standard error in the G band as a function
of G. A 20% margin is included.
Parameters
----------
G - Value(s) of G-band magnitude.
Keywords
--------
nobs - Number of observations collected (default 70).
Returns
-------
The G band photometric standa... | pygaia/errors/photometric.py | def gMagnitudeErrorEoM(G, nobs=70):
"""
Calculate the end of mission photometric standard error in the G band as a function
of G. A 20% margin is included.
Parameters
----------
G - Value(s) of G-band magnitude.
Keywords
--------
nobs - Number of observations collected (default 70).
Return... | def gMagnitudeErrorEoM(G, nobs=70):
"""
Calculate the end of mission photometric standard error in the G band as a function
of G. A 20% margin is included.
Parameters
----------
G - Value(s) of G-band magnitude.
Keywords
--------
nobs - Number of observations collected (default 70).
Return... | [
"Calculate",
"the",
"end",
"of",
"mission",
"photometric",
"standard",
"error",
"in",
"the",
"G",
"band",
"as",
"a",
"function",
"of",
"G",
".",
"A",
"20%",
"margin",
"is",
"included",
"."
] | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/errors/photometric.py#L38-L59 | [
"def",
"gMagnitudeErrorEoM",
"(",
"G",
",",
"nobs",
"=",
"70",
")",
":",
"return",
"sqrt",
"(",
"(",
"power",
"(",
"gMagnitudeError",
"(",
"G",
")",
"/",
"_scienceMargin",
",",
"2",
")",
"+",
"_eomCalibrationFloorG",
"*",
"_eomCalibrationFloorG",
")",
"/",... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | bpMagnitudeError | Calculate the single-field-of-view-transit photometric standard error in the BP band as a function
of G and (V-I). Note: this refers to the integrated flux from the BP spectrophotometer. A margin of 20%
is included.
Parameters
----------
G - Value(s) of G-band magnitude.
vmini - Value(s) of (V-I) colo... | pygaia/errors/photometric.py | def bpMagnitudeError(G, vmini):
"""
Calculate the single-field-of-view-transit photometric standard error in the BP band as a function
of G and (V-I). Note: this refers to the integrated flux from the BP spectrophotometer. A margin of 20%
is included.
Parameters
----------
G - Value(s) of G-band mag... | def bpMagnitudeError(G, vmini):
"""
Calculate the single-field-of-view-transit photometric standard error in the BP band as a function
of G and (V-I). Note: this refers to the integrated flux from the BP spectrophotometer. A margin of 20%
is included.
Parameters
----------
G - Value(s) of G-band mag... | [
"Calculate",
"the",
"single",
"-",
"field",
"-",
"of",
"-",
"view",
"-",
"transit",
"photometric",
"standard",
"error",
"in",
"the",
"BP",
"band",
"as",
"a",
"function",
"of",
"G",
"and",
"(",
"V",
"-",
"I",
")",
".",
"Note",
":",
"this",
"refers",
... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/errors/photometric.py#L61-L82 | [
"def",
"bpMagnitudeError",
"(",
"G",
",",
"vmini",
")",
":",
"z",
"=",
"calcZBpRp",
"(",
"G",
")",
"a",
"=",
"-",
"0.000562",
"*",
"power",
"(",
"vmini",
",",
"3",
")",
"+",
"0.044390",
"*",
"vmini",
"*",
"vmini",
"+",
"0.355123",
"*",
"vmini",
"... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | bpMagnitudeErrorEoM | Calculate the end-of-mission photometric standard error in the BP band as a function of G and (V-I).
Note: this refers to the integrated flux from the BP spectrophotometer. A margin of 20% is included.
Parameters
----------
G - Value(s) of G-band magnitude.
vmini - Value(s) of (V-I) colour.
Keywords
... | pygaia/errors/photometric.py | def bpMagnitudeErrorEoM(G, vmini, nobs=70):
"""
Calculate the end-of-mission photometric standard error in the BP band as a function of G and (V-I).
Note: this refers to the integrated flux from the BP spectrophotometer. A margin of 20% is included.
Parameters
----------
G - Value(s) of G-band magnitu... | def bpMagnitudeErrorEoM(G, vmini, nobs=70):
"""
Calculate the end-of-mission photometric standard error in the BP band as a function of G and (V-I).
Note: this refers to the integrated flux from the BP spectrophotometer. A margin of 20% is included.
Parameters
----------
G - Value(s) of G-band magnitu... | [
"Calculate",
"the",
"end",
"-",
"of",
"-",
"mission",
"photometric",
"standard",
"error",
"in",
"the",
"BP",
"band",
"as",
"a",
"function",
"of",
"G",
"and",
"(",
"V",
"-",
"I",
")",
".",
"Note",
":",
"this",
"refers",
"to",
"the",
"integrated",
"flu... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/errors/photometric.py#L84-L106 | [
"def",
"bpMagnitudeErrorEoM",
"(",
"G",
",",
"vmini",
",",
"nobs",
"=",
"70",
")",
":",
"return",
"sqrt",
"(",
"(",
"power",
"(",
"bpMagnitudeError",
"(",
"G",
",",
"vmini",
")",
"/",
"_scienceMargin",
",",
"2",
")",
"+",
"_eomCalibrationFloorBP",
"*",
... | ae972b0622a15f713ffae471f925eac25ccdae47 |
test | rpMagnitudeErrorEoM | Calculate the end-of-mission photometric standard error in the RP band as a function of G and (V-I).
Note: this refers to the integrated flux from the RP spectrophotometer. A margin of 20% is included.
Parameters
----------
G - Value(s) of G-band magnitude.
vmini - Value(s) of (V-I) colour.
Keywords
... | pygaia/errors/photometric.py | def rpMagnitudeErrorEoM(G, vmini, nobs=70):
"""
Calculate the end-of-mission photometric standard error in the RP band as a function of G and (V-I).
Note: this refers to the integrated flux from the RP spectrophotometer. A margin of 20% is included.
Parameters
----------
G - Value(s) of G-band magnitu... | def rpMagnitudeErrorEoM(G, vmini, nobs=70):
"""
Calculate the end-of-mission photometric standard error in the RP band as a function of G and (V-I).
Note: this refers to the integrated flux from the RP spectrophotometer. A margin of 20% is included.
Parameters
----------
G - Value(s) of G-band magnitu... | [
"Calculate",
"the",
"end",
"-",
"of",
"-",
"mission",
"photometric",
"standard",
"error",
"in",
"the",
"RP",
"band",
"as",
"a",
"function",
"of",
"G",
"and",
"(",
"V",
"-",
"I",
")",
".",
"Note",
":",
"this",
"refers",
"to",
"the",
"integrated",
"flu... | agabrown/PyGaia | python | https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/pygaia/errors/photometric.py#L131-L153 | [
"def",
"rpMagnitudeErrorEoM",
"(",
"G",
",",
"vmini",
",",
"nobs",
"=",
"70",
")",
":",
"return",
"sqrt",
"(",
"(",
"power",
"(",
"rpMagnitudeError",
"(",
"G",
",",
"vmini",
")",
"/",
"_scienceMargin",
",",
"2",
")",
"+",
"_eomCalibrationFloorRP",
"*",
... | ae972b0622a15f713ffae471f925eac25ccdae47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.