id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
45,400 | pkgw/pwkit | pwkit/sherpa.py | derive_identity_arf | def derive_identity_arf(name, arf):
"""Create an "identity" ARF that has uniform sensitivity.
*name*
The name of the ARF object to be created; passed to Sherpa.
*arf*
An existing ARF object on which to base this one.
Returns:
A new ARF1D object that has a uniform spectral response vec... | python | def derive_identity_arf(name, arf):
"""Create an "identity" ARF that has uniform sensitivity.
*name*
The name of the ARF object to be created; passed to Sherpa.
*arf*
An existing ARF object on which to base this one.
Returns:
A new ARF1D object that has a uniform spectral response vec... | [
"def",
"derive_identity_arf",
"(",
"name",
",",
"arf",
")",
":",
"from",
"sherpa",
".",
"astro",
".",
"data",
"import",
"DataARF",
"from",
"sherpa",
".",
"astro",
".",
"instrument",
"import",
"ARF1D",
"darf",
"=",
"DataARF",
"(",
"name",
",",
"arf",
".",... | Create an "identity" ARF that has uniform sensitivity.
*name*
The name of the ARF object to be created; passed to Sherpa.
*arf*
An existing ARF object on which to base this one.
Returns:
A new ARF1D object that has a uniform spectral response vector.
In many X-ray observations, the r... | [
"Create",
"an",
"identity",
"ARF",
"that",
"has",
"uniform",
"sensitivity",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L340-L372 |
45,401 | pkgw/pwkit | pwkit/sherpa.py | get_source_qq_data | def get_source_qq_data(id=None):
"""Get data for a quantile-quantile plot of the source data and model.
*id*
The dataset id for which to get the data; defaults if unspecified.
Returns:
An ndarray of shape ``(3, npts)``. The first slice is the energy axis in
keV; the second is the observed... | python | def get_source_qq_data(id=None):
"""Get data for a quantile-quantile plot of the source data and model.
*id*
The dataset id for which to get the data; defaults if unspecified.
Returns:
An ndarray of shape ``(3, npts)``. The first slice is the energy axis in
keV; the second is the observed... | [
"def",
"get_source_qq_data",
"(",
"id",
"=",
"None",
")",
":",
"sdata",
"=",
"ui",
".",
"get_data",
"(",
"id",
"=",
"id",
")",
"kev",
"=",
"sdata",
".",
"get_x",
"(",
")",
"obs_data",
"=",
"sdata",
".",
"counts",
"model_data",
"=",
"ui",
".",
"get_... | Get data for a quantile-quantile plot of the source data and model.
*id*
The dataset id for which to get the data; defaults if unspecified.
Returns:
An ndarray of shape ``(3, npts)``. The first slice is the energy axis in
keV; the second is the observed values in each bin (counts, or rate, or... | [
"Get",
"data",
"for",
"a",
"quantile",
"-",
"quantile",
"plot",
"of",
"the",
"source",
"data",
"and",
"model",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L375-L394 |
45,402 | pkgw/pwkit | pwkit/sherpa.py | get_bkg_qq_data | def get_bkg_qq_data(id=None, bkg_id=None):
"""Get data for a quantile-quantile plot of the background data and model.
*id*
The dataset id for which to get the data; defaults if unspecified.
*bkg_id*
The identifier of the background; defaults if unspecified.
Returns:
An ndarray of shap... | python | def get_bkg_qq_data(id=None, bkg_id=None):
"""Get data for a quantile-quantile plot of the background data and model.
*id*
The dataset id for which to get the data; defaults if unspecified.
*bkg_id*
The identifier of the background; defaults if unspecified.
Returns:
An ndarray of shap... | [
"def",
"get_bkg_qq_data",
"(",
"id",
"=",
"None",
",",
"bkg_id",
"=",
"None",
")",
":",
"bdata",
"=",
"ui",
".",
"get_bkg",
"(",
"id",
"=",
"id",
",",
"bkg_id",
"=",
"bkg_id",
")",
"kev",
"=",
"bdata",
".",
"get_x",
"(",
")",
"obs_data",
"=",
"bd... | Get data for a quantile-quantile plot of the background data and model.
*id*
The dataset id for which to get the data; defaults if unspecified.
*bkg_id*
The identifier of the background; defaults if unspecified.
Returns:
An ndarray of shape ``(3, npts)``. The first slice is the energy axi... | [
"Get",
"data",
"for",
"a",
"quantile",
"-",
"quantile",
"plot",
"of",
"the",
"background",
"data",
"and",
"model",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L397-L418 |
45,403 | pkgw/pwkit | pwkit/sherpa.py | make_qq_plot | def make_qq_plot(kev, obs, mdl, unit, key_text):
"""Make a quantile-quantile plot comparing events and a model.
*kev*
A 1D, sorted array of event energy bins measured in keV.
*obs*
A 1D array giving the number or rate of events in each bin.
*mdl*
A 1D array giving the modeled number o... | python | def make_qq_plot(kev, obs, mdl, unit, key_text):
"""Make a quantile-quantile plot comparing events and a model.
*kev*
A 1D, sorted array of event energy bins measured in keV.
*obs*
A 1D array giving the number or rate of events in each bin.
*mdl*
A 1D array giving the modeled number o... | [
"def",
"make_qq_plot",
"(",
"kev",
",",
"obs",
",",
"mdl",
",",
"unit",
",",
"key_text",
")",
":",
"import",
"omega",
"as",
"om",
"kev",
"=",
"np",
".",
"asarray",
"(",
"kev",
")",
"obs",
"=",
"np",
".",
"asarray",
"(",
"obs",
")",
"mdl",
"=",
... | Make a quantile-quantile plot comparing events and a model.
*kev*
A 1D, sorted array of event energy bins measured in keV.
*obs*
A 1D array giving the number or rate of events in each bin.
*mdl*
A 1D array giving the modeled number or rate of events in each bin.
*unit*
Text desc... | [
"Make",
"a",
"quantile",
"-",
"quantile",
"plot",
"comparing",
"events",
"and",
"a",
"model",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L421-L475 |
45,404 | pkgw/pwkit | pwkit/sherpa.py | make_multi_qq_plots | def make_multi_qq_plots(arrays, key_text):
"""Make a quantile-quantile plot comparing multiple sets of events and models.
*arrays*
X.
*key_text*
Text describing the quantile-quantile comparison quantity; will be
shown on the plot legend.
Returns:
An :class:`omega.RectPlot` insta... | python | def make_multi_qq_plots(arrays, key_text):
"""Make a quantile-quantile plot comparing multiple sets of events and models.
*arrays*
X.
*key_text*
Text describing the quantile-quantile comparison quantity; will be
shown on the plot legend.
Returns:
An :class:`omega.RectPlot` insta... | [
"def",
"make_multi_qq_plots",
"(",
"arrays",
",",
"key_text",
")",
":",
"import",
"omega",
"as",
"om",
"p",
"=",
"om",
".",
"RectPlot",
"(",
")",
"p",
".",
"addXY",
"(",
"[",
"0",
",",
"1.",
"]",
",",
"[",
"0",
",",
"1.",
"]",
",",
"'1:1'",
")"... | Make a quantile-quantile plot comparing multiple sets of events and models.
*arrays*
X.
*key_text*
Text describing the quantile-quantile comparison quantity; will be
shown on the plot legend.
Returns:
An :class:`omega.RectPlot` instance.
*TODO*: nothing about this is Sherpa-spe... | [
"Make",
"a",
"quantile",
"-",
"quantile",
"plot",
"comparing",
"multiple",
"sets",
"of",
"events",
"and",
"models",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L478-L531 |
45,405 | pkgw/pwkit | pwkit/sherpa.py | make_spectrum_plot | def make_spectrum_plot(model_plot, data_plot, desc, xmin_clamp=0.01,
min_valid_x=None, max_valid_x=None):
"""Make a plot of a spectral model and data.
*model_plot*
A model plot object returned by Sherpa from a call like `ui.get_model_plot()`
or `ui.get_bkg_model_plot()`.
... | python | def make_spectrum_plot(model_plot, data_plot, desc, xmin_clamp=0.01,
min_valid_x=None, max_valid_x=None):
"""Make a plot of a spectral model and data.
*model_plot*
A model plot object returned by Sherpa from a call like `ui.get_model_plot()`
or `ui.get_bkg_model_plot()`.
... | [
"def",
"make_spectrum_plot",
"(",
"model_plot",
",",
"data_plot",
",",
"desc",
",",
"xmin_clamp",
"=",
"0.01",
",",
"min_valid_x",
"=",
"None",
",",
"max_valid_x",
"=",
"None",
")",
":",
"import",
"omega",
"as",
"om",
"model_x",
"=",
"np",
".",
"concatenat... | Make a plot of a spectral model and data.
*model_plot*
A model plot object returned by Sherpa from a call like `ui.get_model_plot()`
or `ui.get_bkg_model_plot()`.
*data_plot*
A data plot object returned by Sherpa from a call like `ui.get_source_plot()`
or `ui.get_bkg_plot()`.
*desc*... | [
"Make",
"a",
"plot",
"of",
"a",
"spectral",
"model",
"and",
"data",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L534-L606 |
45,406 | bibanon/BASC-py4chan | examples/example6-download-thread.py | download_file | def download_file(local_filename, url, clobber=False):
"""Download the given file. Clobber overwrites file if exists."""
dir_name = os.path.dirname(local_filename)
mkdirs(dir_name)
if clobber or not os.path.exists(local_filename):
i = requests.get(url)
# if not exists
if i.stat... | python | def download_file(local_filename, url, clobber=False):
"""Download the given file. Clobber overwrites file if exists."""
dir_name = os.path.dirname(local_filename)
mkdirs(dir_name)
if clobber or not os.path.exists(local_filename):
i = requests.get(url)
# if not exists
if i.stat... | [
"def",
"download_file",
"(",
"local_filename",
",",
"url",
",",
"clobber",
"=",
"False",
")",
":",
"dir_name",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"local_filename",
")",
"mkdirs",
"(",
"dir_name",
")",
"if",
"clobber",
"or",
"not",
"os",
".",
... | Download the given file. Clobber overwrites file if exists. | [
"Download",
"the",
"given",
"file",
".",
"Clobber",
"overwrites",
"file",
"if",
"exists",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/examples/example6-download-thread.py#L14-L33 |
45,407 | bibanon/BASC-py4chan | examples/example6-download-thread.py | download_json | def download_json(local_filename, url, clobber=False):
"""Download the given JSON file, and pretty-print before we output it."""
with open(local_filename, 'w') as json_file:
json_file.write(json.dumps(requests.get(url).json(), sort_keys=True, indent=2, separators=(',', ': '))) | python | def download_json(local_filename, url, clobber=False):
"""Download the given JSON file, and pretty-print before we output it."""
with open(local_filename, 'w') as json_file:
json_file.write(json.dumps(requests.get(url).json(), sort_keys=True, indent=2, separators=(',', ': '))) | [
"def",
"download_json",
"(",
"local_filename",
",",
"url",
",",
"clobber",
"=",
"False",
")",
":",
"with",
"open",
"(",
"local_filename",
",",
"'w'",
")",
"as",
"json_file",
":",
"json_file",
".",
"write",
"(",
"json",
".",
"dumps",
"(",
"requests",
".",... | Download the given JSON file, and pretty-print before we output it. | [
"Download",
"the",
"given",
"JSON",
"file",
"and",
"pretty",
"-",
"print",
"before",
"we",
"output",
"it",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/examples/example6-download-thread.py#L35-L38 |
45,408 | pkgw/pwkit | pwkit/data_gui_helpers.py | data_to_argb32 | def data_to_argb32 (data, cmin=None, cmax=None, stretch='linear', cmap='black_to_blue'):
"""Turn arbitrary data values into ARGB32 colors.
There are three steps to this process: clipping the data values to a
maximum and minimum; stretching the spacing between those values; and
converting their amplitud... | python | def data_to_argb32 (data, cmin=None, cmax=None, stretch='linear', cmap='black_to_blue'):
"""Turn arbitrary data values into ARGB32 colors.
There are three steps to this process: clipping the data values to a
maximum and minimum; stretching the spacing between those values; and
converting their amplitud... | [
"def",
"data_to_argb32",
"(",
"data",
",",
"cmin",
"=",
"None",
",",
"cmax",
"=",
"None",
",",
"stretch",
"=",
"'linear'",
",",
"cmap",
"=",
"'black_to_blue'",
")",
":",
"# This could be more efficient, but whatever. This lets us share code with",
"# the ndshow module."... | Turn arbitrary data values into ARGB32 colors.
There are three steps to this process: clipping the data values to a
maximum and minimum; stretching the spacing between those values; and
converting their amplitudes into colors with some kind of color map.
`data` - Input data; can (and should) be a M... | [
"Turn",
"arbitrary",
"data",
"values",
"into",
"ARGB32",
"colors",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/data_gui_helpers.py#L217-L261 |
45,409 | pkgw/pwkit | pwkit/data_gui_helpers.py | data_to_imagesurface | def data_to_imagesurface (data, **kwargs):
"""Turn arbitrary data values into a Cairo ImageSurface.
The method and arguments are the same as data_to_argb32, except that the
data array will be treated as 2D, and higher dimensionalities are not
allowed. The return value is a Cairo ImageSurface object.
... | python | def data_to_imagesurface (data, **kwargs):
"""Turn arbitrary data values into a Cairo ImageSurface.
The method and arguments are the same as data_to_argb32, except that the
data array will be treated as 2D, and higher dimensionalities are not
allowed. The return value is a Cairo ImageSurface object.
... | [
"def",
"data_to_imagesurface",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"cairo",
"data",
"=",
"np",
".",
"atleast_2d",
"(",
"data",
")",
"if",
"data",
".",
"ndim",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'input array may not have more... | Turn arbitrary data values into a Cairo ImageSurface.
The method and arguments are the same as data_to_argb32, except that the
data array will be treated as 2D, and higher dimensionalities are not
allowed. The return value is a Cairo ImageSurface object.
Combined with the write_to_png() method on Imag... | [
"Turn",
"arbitrary",
"data",
"values",
"into",
"a",
"Cairo",
"ImageSurface",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/data_gui_helpers.py#L264-L291 |
45,410 | ferittuncer/ITU-Turkish-NLP-Pipeline-Caller | pipeline_caller.py | get_token | def get_token(filename=TOKEN_PATH, envvar=TOKEN_ENVVAR):
"""
Returns pipeline_token for API
Tries local file first, then env variable
"""
if os.path.isfile(filename):
with open(filename) as token_file:
token = token_file.readline().strip()
else:
token = os.environ.g... | python | def get_token(filename=TOKEN_PATH, envvar=TOKEN_ENVVAR):
"""
Returns pipeline_token for API
Tries local file first, then env variable
"""
if os.path.isfile(filename):
with open(filename) as token_file:
token = token_file.readline().strip()
else:
token = os.environ.g... | [
"def",
"get_token",
"(",
"filename",
"=",
"TOKEN_PATH",
",",
"envvar",
"=",
"TOKEN_ENVVAR",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"token_file",
":",
"token",
"=",
"token... | Returns pipeline_token for API
Tries local file first, then env variable | [
"Returns",
"pipeline_token",
"for",
"API"
] | 602ee50d2b6f6e9937192b6a03ce91907a04f3d2 | https://github.com/ferittuncer/ITU-Turkish-NLP-Pipeline-Caller/blob/602ee50d2b6f6e9937192b6a03ce91907a04f3d2/pipeline_caller.py#L103-L120 |
45,411 | pkgw/pwkit | pwkit/environments/casa/gpdiagnostics.py | GainCal.stats | def stats (self, antnames):
"""XXX may be out of date."""
nbyant = np.zeros (self.nants, dtype=np.int)
sum = np.zeros (self.nants, dtype=np.complex)
sumsq = np.zeros (self.nants)
q = np.abs (self.normvis - 1)
for i in range (self.nsamps):
i1, i2 = self.blidxs... | python | def stats (self, antnames):
"""XXX may be out of date."""
nbyant = np.zeros (self.nants, dtype=np.int)
sum = np.zeros (self.nants, dtype=np.complex)
sumsq = np.zeros (self.nants)
q = np.abs (self.normvis - 1)
for i in range (self.nsamps):
i1, i2 = self.blidxs... | [
"def",
"stats",
"(",
"self",
",",
"antnames",
")",
":",
"nbyant",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"nants",
",",
"dtype",
"=",
"np",
".",
"int",
")",
"sum",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"nants",
",",
"dtype",
"=",
"np",
... | XXX may be out of date. | [
"XXX",
"may",
"be",
"out",
"of",
"date",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/gpdiagnostics.py#L220-L243 |
45,412 | pkgw/pwkit | pwkit/lmmin.py | _qr_factor_packed | def _qr_factor_packed(a, enorm, finfo):
"""Compute the packed pivoting Q-R factorization of a matrix.
Parameters:
a - An n-by-m matrix, m >= n. This will be *overwritten*
by this function as described below!
enorm - A Euclidian-norm-computing function.
finfo - A Numpy finfo object.
Returns:
pmut - A... | python | def _qr_factor_packed(a, enorm, finfo):
"""Compute the packed pivoting Q-R factorization of a matrix.
Parameters:
a - An n-by-m matrix, m >= n. This will be *overwritten*
by this function as described below!
enorm - A Euclidian-norm-computing function.
finfo - A Numpy finfo object.
Returns:
pmut - A... | [
"def",
"_qr_factor_packed",
"(",
"a",
",",
"enorm",
",",
"finfo",
")",
":",
"machep",
"=",
"finfo",
".",
"eps",
"n",
",",
"m",
"=",
"a",
".",
"shape",
"if",
"m",
"<",
"n",
":",
"raise",
"ValueError",
"(",
"'\"a\" must be at least as tall as it is wide'",
... | Compute the packed pivoting Q-R factorization of a matrix.
Parameters:
a - An n-by-m matrix, m >= n. This will be *overwritten*
by this function as described below!
enorm - A Euclidian-norm-computing function.
finfo - A Numpy finfo object.
Returns:
pmut - An n-element permutation vector
rdiag - An n-el... | [
"Compute",
"the",
"packed",
"pivoting",
"Q",
"-",
"R",
"factorization",
"of",
"a",
"matrix",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lmmin.py#L355-L477 |
45,413 | pkgw/pwkit | pwkit/lmmin.py | _qr_factor_full | def _qr_factor_full(a, dtype=np.float):
"""Compute the QR factorization of a matrix, with pivoting.
Parameters:
a - An n-by-m arraylike, m >= n.
dtype - (optional) The data type to use for computations.
Default is np.float.
Returns:
q - An m-by-m orthogonal matrix (q q^T = ident)
r - An n-by-m u... | python | def _qr_factor_full(a, dtype=np.float):
"""Compute the QR factorization of a matrix, with pivoting.
Parameters:
a - An n-by-m arraylike, m >= n.
dtype - (optional) The data type to use for computations.
Default is np.float.
Returns:
q - An m-by-m orthogonal matrix (q q^T = ident)
r - An n-by-m u... | [
"def",
"_qr_factor_full",
"(",
"a",
",",
"dtype",
"=",
"np",
".",
"float",
")",
":",
"n",
",",
"m",
"=",
"a",
".",
"shape",
"# Compute the packed Q and R matrix information.",
"packed",
",",
"pmut",
",",
"rdiag",
",",
"acnorm",
"=",
"_manual_qr_factor_packed",... | Compute the QR factorization of a matrix, with pivoting.
Parameters:
a - An n-by-m arraylike, m >= n.
dtype - (optional) The data type to use for computations.
Default is np.float.
Returns:
q - An m-by-m orthogonal matrix (q q^T = ident)
r - An n-by-m upper triangular matrix
pmut - An n-element perm... | [
"Compute",
"the",
"QR",
"factorization",
"of",
"a",
"matrix",
"with",
"pivoting",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lmmin.py#L490-L549 |
45,414 | pkgw/pwkit | pwkit/lmmin.py | _qrd_solve | def _qrd_solve(r, pmut, ddiag, bqt, sdiag):
"""Solve an equation given a QR factored matrix and a diagonal.
Parameters:
r - **input-output** n-by-n array. The full lower triangle contains
the full lower triangle of R. On output, the strict upper
triangle contains the transpose of the strict low... | python | def _qrd_solve(r, pmut, ddiag, bqt, sdiag):
"""Solve an equation given a QR factored matrix and a diagonal.
Parameters:
r - **input-output** n-by-n array. The full lower triangle contains
the full lower triangle of R. On output, the strict upper
triangle contains the transpose of the strict low... | [
"def",
"_qrd_solve",
"(",
"r",
",",
"pmut",
",",
"ddiag",
",",
"bqt",
",",
"sdiag",
")",
":",
"n",
",",
"m",
"=",
"r",
".",
"shape",
"# \"Copy r and bqt to preserve input and initialize s. In",
"# particular, save the diagonal elements of r in x.\" Recall that",
"# on... | Solve an equation given a QR factored matrix and a diagonal.
Parameters:
r - **input-output** n-by-n array. The full lower triangle contains
the full lower triangle of R. On output, the strict upper
triangle contains the transpose of the strict lower triangle of
S.
pmut - n-vector describi... | [
"Solve",
"an",
"equation",
"given",
"a",
"QR",
"factored",
"matrix",
"and",
"a",
"diagonal",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lmmin.py#L615-L747 |
45,415 | pkgw/pwkit | pwkit/lmmin.py | _qrd_solve_full | def _qrd_solve_full(a, b, ddiag, dtype=np.float):
"""Solve the equation A^T x = B, D x = 0.
Parameters:
a - an n-by-m array, m >= n
b - an m-vector
ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.)
Returns:
x - n-vector solving the equation.
s - the n-by-n supplementary matrix s.
p... | python | def _qrd_solve_full(a, b, ddiag, dtype=np.float):
"""Solve the equation A^T x = B, D x = 0.
Parameters:
a - an n-by-m array, m >= n
b - an m-vector
ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.)
Returns:
x - n-vector solving the equation.
s - the n-by-n supplementary matrix s.
p... | [
"def",
"_qrd_solve_full",
"(",
"a",
",",
"b",
",",
"ddiag",
",",
"dtype",
"=",
"np",
".",
"float",
")",
":",
"a",
"=",
"np",
".",
"asarray",
"(",
"a",
",",
"dtype",
")",
"b",
"=",
"np",
".",
"asarray",
"(",
"b",
",",
"dtype",
")",
"ddiag",
"=... | Solve the equation A^T x = B, D x = 0.
Parameters:
a - an n-by-m array, m >= n
b - an m-vector
ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.)
Returns:
x - n-vector solving the equation.
s - the n-by-n supplementary matrix s.
pmut - n-element permutation vector defining the permutati... | [
"Solve",
"the",
"equation",
"A^T",
"x",
"=",
"B",
"D",
"x",
"=",
"0",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lmmin.py#L774-L815 |
45,416 | pkgw/pwkit | pwkit/lmmin.py | _calc_covariance | def _calc_covariance(r, pmut, tol=1e-14):
"""Calculate the covariance matrix of the fitted parameters
Parameters:
r - n-by-n matrix, the full upper triangle of R
pmut - n-vector, defines the permutation of R
tol - scalar, relative column scale for determining rank
deficiency. Default 1e-14.
Returns:
co... | python | def _calc_covariance(r, pmut, tol=1e-14):
"""Calculate the covariance matrix of the fitted parameters
Parameters:
r - n-by-n matrix, the full upper triangle of R
pmut - n-vector, defines the permutation of R
tol - scalar, relative column scale for determining rank
deficiency. Default 1e-14.
Returns:
co... | [
"def",
"_calc_covariance",
"(",
"r",
",",
"pmut",
",",
"tol",
"=",
"1e-14",
")",
":",
"# This routine could save an allocation by operating on r in-place,",
"# which might be worthwhile for large n, and is what the original",
"# Fortran does.",
"n",
"=",
"r",
".",
"shape",
"[... | Calculate the covariance matrix of the fitted parameters
Parameters:
r - n-by-n matrix, the full upper triangle of R
pmut - n-vector, defines the permutation of R
tol - scalar, relative column scale for determining rank
deficiency. Default 1e-14.
Returns:
cov - n-by-n matrix, the covariance matrix C
Give... | [
"Calculate",
"the",
"covariance",
"matrix",
"of",
"the",
"fitted",
"parameters"
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lmmin.py#L1064-L1162 |
45,417 | pkgw/pwkit | pwkit/cli/multitool.py | invoke_tool | def invoke_tool (namespace, tool_class=None):
"""Invoke a tool and exit.
`namespace` is a namespace-type dict from which the tool is initialized.
It should contain exactly one value that is a `Multitool` subclass, and
this subclass will be instantiated and populated (see
`Multitool.populate()`) usi... | python | def invoke_tool (namespace, tool_class=None):
"""Invoke a tool and exit.
`namespace` is a namespace-type dict from which the tool is initialized.
It should contain exactly one value that is a `Multitool` subclass, and
this subclass will be instantiated and populated (see
`Multitool.populate()`) usi... | [
"def",
"invoke_tool",
"(",
"namespace",
",",
"tool_class",
"=",
"None",
")",
":",
"import",
"sys",
"from",
".",
".",
"import",
"cli",
"cli",
".",
"propagate_sigint",
"(",
")",
"cli",
".",
"unicode_stdio",
"(",
")",
"cli",
".",
"backtrace_on_usr1",
"(",
"... | Invoke a tool and exit.
`namespace` is a namespace-type dict from which the tool is initialized.
It should contain exactly one value that is a `Multitool` subclass, and
this subclass will be instantiated and populated (see
`Multitool.populate()`) using the other items in the namespace. Instances
an... | [
"Invoke",
"a",
"tool",
"and",
"exit",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/multitool.py#L361-L404 |
45,418 | pkgw/pwkit | pwkit/cli/multitool.py | ArgparsingCommand.get_arg_parser | def get_arg_parser (self, **kwargs):
"""Return an instance of `argparse.ArgumentParser` used to process
this tool's command-line arguments.
"""
import argparse
ap = argparse.ArgumentParser (
prog = kwargs['argv0'],
description = self.summary,
)
... | python | def get_arg_parser (self, **kwargs):
"""Return an instance of `argparse.ArgumentParser` used to process
this tool's command-line arguments.
"""
import argparse
ap = argparse.ArgumentParser (
prog = kwargs['argv0'],
description = self.summary,
)
... | [
"def",
"get_arg_parser",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"argparse",
"ap",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"kwargs",
"[",
"'argv0'",
"]",
",",
"description",
"=",
"self",
".",
"summary",
",",
")",
"re... | Return an instance of `argparse.ArgumentParser` used to process
this tool's command-line arguments. | [
"Return",
"an",
"instance",
"of",
"argparse",
".",
"ArgumentParser",
"used",
"to",
"process",
"this",
"tool",
"s",
"command",
"-",
"line",
"arguments",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/multitool.py#L165-L175 |
45,419 | pkgw/pwkit | pwkit/cli/multitool.py | DelegatingCommand.register | def register (self, cmd):
"""Register a new command with the tool. 'cmd' is expected to be an instance
of `Command`, although here only the `cmd.name` attribute is
investigated. Multiple commands with the same name are not allowed to
be registered. Returns 'self'.
"""
if... | python | def register (self, cmd):
"""Register a new command with the tool. 'cmd' is expected to be an instance
of `Command`, although here only the `cmd.name` attribute is
investigated. Multiple commands with the same name are not allowed to
be registered. Returns 'self'.
"""
if... | [
"def",
"register",
"(",
"self",
",",
"cmd",
")",
":",
"if",
"cmd",
".",
"name",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'no name set for Command object %r'",
"%",
"cmd",
")",
"if",
"cmd",
".",
"name",
"in",
"self",
".",
"commands",
":",
"raise",
... | Register a new command with the tool. 'cmd' is expected to be an instance
of `Command`, although here only the `cmd.name` attribute is
investigated. Multiple commands with the same name are not allowed to
be registered. Returns 'self'. | [
"Register",
"a",
"new",
"command",
"with",
"the",
"tool",
".",
"cmd",
"is",
"expected",
"to",
"be",
"an",
"instance",
"of",
"Command",
"although",
"here",
"only",
"the",
"cmd",
".",
"name",
"attribute",
"is",
"investigated",
".",
"Multiple",
"commands",
"w... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/multitool.py#L243-L257 |
45,420 | pkgw/pwkit | pwkit/cli/multitool.py | DelegatingCommand.invoke_command | def invoke_command (self, cmd, args, **kwargs):
"""This function mainly exists to be overridden by subclasses."""
new_kwargs = kwargs.copy ()
new_kwargs['argv0'] = kwargs['argv0'] + ' ' + cmd.name
new_kwargs['parent'] = self
new_kwargs['parent_kwargs'] = kwargs
return cmd... | python | def invoke_command (self, cmd, args, **kwargs):
"""This function mainly exists to be overridden by subclasses."""
new_kwargs = kwargs.copy ()
new_kwargs['argv0'] = kwargs['argv0'] + ' ' + cmd.name
new_kwargs['parent'] = self
new_kwargs['parent_kwargs'] = kwargs
return cmd... | [
"def",
"invoke_command",
"(",
"self",
",",
"cmd",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"new_kwargs",
"=",
"kwargs",
".",
"copy",
"(",
")",
"new_kwargs",
"[",
"'argv0'",
"]",
"=",
"kwargs",
"[",
"'argv0'",
"]",
"+",
"' '",
"+",
"cmd",
"."... | This function mainly exists to be overridden by subclasses. | [
"This",
"function",
"mainly",
"exists",
"to",
"be",
"overridden",
"by",
"subclasses",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/multitool.py#L277-L283 |
45,421 | pkgw/pwkit | pwkit/cli/latexdriver.py | merge_bibtex_collections | def merge_bibtex_collections(citednames, maindict, extradicts, allow_missing=False):
"""There must be a way to be efficient and stream output instead of loading
everything into memory at once, but, meh.
Note that we augment `citednames` with all of the names in `maindict`. The
intention is that if we'v... | python | def merge_bibtex_collections(citednames, maindict, extradicts, allow_missing=False):
"""There must be a way to be efficient and stream output instead of loading
everything into memory at once, but, meh.
Note that we augment `citednames` with all of the names in `maindict`. The
intention is that if we'v... | [
"def",
"merge_bibtex_collections",
"(",
"citednames",
",",
"maindict",
",",
"extradicts",
",",
"allow_missing",
"=",
"False",
")",
":",
"allrecords",
"=",
"{",
"}",
"for",
"ed",
"in",
"extradicts",
":",
"allrecords",
".",
"update",
"(",
"ed",
")",
"allrecord... | There must be a way to be efficient and stream output instead of loading
everything into memory at once, but, meh.
Note that we augment `citednames` with all of the names in `maindict`. The
intention is that if we've gone to the effort of getting good data for
some record, we don't want to trash it if ... | [
"There",
"must",
"be",
"a",
"way",
"to",
"be",
"efficient",
"and",
"stream",
"output",
"instead",
"of",
"loading",
"everything",
"into",
"memory",
"at",
"once",
"but",
"meh",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/latexdriver.py#L52-L89 |
45,422 | pkgw/pwkit | pwkit/cli/latexdriver.py | write_bibtex_dict | def write_bibtex_dict(stream, entries):
"""bibtexparser.write converts the entire database to one big string and
writes it out in one go. I'm sure it will always all fit in RAM but some
things just will not stand.
"""
from bibtexparser.bwriter import BibTexWriter
writer = BibTexWriter()
wr... | python | def write_bibtex_dict(stream, entries):
"""bibtexparser.write converts the entire database to one big string and
writes it out in one go. I'm sure it will always all fit in RAM but some
things just will not stand.
"""
from bibtexparser.bwriter import BibTexWriter
writer = BibTexWriter()
wr... | [
"def",
"write_bibtex_dict",
"(",
"stream",
",",
"entries",
")",
":",
"from",
"bibtexparser",
".",
"bwriter",
"import",
"BibTexWriter",
"writer",
"=",
"BibTexWriter",
"(",
")",
"writer",
".",
"indent",
"=",
"' '",
"writer",
".",
"entry_separator",
"=",
"''",
... | bibtexparser.write converts the entire database to one big string and
writes it out in one go. I'm sure it will always all fit in RAM but some
things just will not stand. | [
"bibtexparser",
".",
"write",
"converts",
"the",
"entire",
"database",
"to",
"one",
"big",
"string",
"and",
"writes",
"it",
"out",
"in",
"one",
"go",
".",
"I",
"m",
"sure",
"it",
"will",
"always",
"all",
"fit",
"in",
"RAM",
"but",
"some",
"things",
"ju... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/latexdriver.py#L105-L123 |
45,423 | pkgw/pwkit | pwkit/cli/latexdriver.py | merge_bibtex_with_aux | def merge_bibtex_with_aux(auxpath, mainpath, extradir, parse=get_bibtex_dict, allow_missing=False):
"""Merge multiple BibTeX files into a single homogeneously-formatted output,
using a LaTeX .aux file to know which records are worth paying attention
to.
The file identified by `mainpath` will be overwri... | python | def merge_bibtex_with_aux(auxpath, mainpath, extradir, parse=get_bibtex_dict, allow_missing=False):
"""Merge multiple BibTeX files into a single homogeneously-formatted output,
using a LaTeX .aux file to know which records are worth paying attention
to.
The file identified by `mainpath` will be overwri... | [
"def",
"merge_bibtex_with_aux",
"(",
"auxpath",
",",
"mainpath",
",",
"extradir",
",",
"parse",
"=",
"get_bibtex_dict",
",",
"allow_missing",
"=",
"False",
")",
":",
"auxpath",
"=",
"Path",
"(",
"auxpath",
")",
"mainpath",
"=",
"Path",
"(",
"mainpath",
")",
... | Merge multiple BibTeX files into a single homogeneously-formatted output,
using a LaTeX .aux file to know which records are worth paying attention
to.
The file identified by `mainpath` will be overwritten with the new .bib
contents. This function is intended to be used in a version-control
context.... | [
"Merge",
"multiple",
"BibTeX",
"files",
"into",
"a",
"single",
"homogeneously",
"-",
"formatted",
"output",
"using",
"a",
"LaTeX",
".",
"aux",
"file",
"to",
"know",
"which",
"records",
"are",
"worth",
"paying",
"attention",
"to",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/latexdriver.py#L126-L165 |
45,424 | pkgw/pwkit | pwkit/cli/latexdriver.py | just_smart_bibtools | def just_smart_bibtools(bib_style, aux, bib):
"""Tectonic has taken over most of the features that this tool used to provide,
but here's a hack to keep my smart .bib file generation working.
"""
extradir = Path('.bibtex')
extradir.ensure_dir(parents=True)
bib_export(bib_style, aux, extradir / ... | python | def just_smart_bibtools(bib_style, aux, bib):
"""Tectonic has taken over most of the features that this tool used to provide,
but here's a hack to keep my smart .bib file generation working.
"""
extradir = Path('.bibtex')
extradir.ensure_dir(parents=True)
bib_export(bib_style, aux, extradir / ... | [
"def",
"just_smart_bibtools",
"(",
"bib_style",
",",
"aux",
",",
"bib",
")",
":",
"extradir",
"=",
"Path",
"(",
"'.bibtex'",
")",
"extradir",
".",
"ensure_dir",
"(",
"parents",
"=",
"True",
")",
"bib_export",
"(",
"bib_style",
",",
"aux",
",",
"extradir",
... | Tectonic has taken over most of the features that this tool used to provide,
but here's a hack to keep my smart .bib file generation working. | [
"Tectonic",
"has",
"taken",
"over",
"most",
"of",
"the",
"features",
"that",
"this",
"tool",
"used",
"to",
"provide",
"but",
"here",
"s",
"a",
"hack",
"to",
"keep",
"my",
"smart",
".",
"bib",
"file",
"generation",
"working",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/latexdriver.py#L319-L329 |
45,425 | pkgw/pwkit | pwkit/environments/casa/closures.py | aap_to_bp | def aap_to_bp (ant1, ant2, pol):
"""Create a basepol from antenna numbers and a CASA polarization code."""
if ant1 < 0:
raise ValueError ('first antenna is below 0: %s' % ant1)
if ant2 < ant1:
raise ValueError ('second antenna is below first: %s' % ant2)
if pol < 1 or pol > 12:
... | python | def aap_to_bp (ant1, ant2, pol):
"""Create a basepol from antenna numbers and a CASA polarization code."""
if ant1 < 0:
raise ValueError ('first antenna is below 0: %s' % ant1)
if ant2 < ant1:
raise ValueError ('second antenna is below first: %s' % ant2)
if pol < 1 or pol > 12:
... | [
"def",
"aap_to_bp",
"(",
"ant1",
",",
"ant2",
",",
"pol",
")",
":",
"if",
"ant1",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'first antenna is below 0: %s'",
"%",
"ant1",
")",
"if",
"ant2",
"<",
"ant1",
":",
"raise",
"ValueError",
"(",
"'second antenna is... | Create a basepol from antenna numbers and a CASA polarization code. | [
"Create",
"a",
"basepol",
"from",
"antenna",
"numbers",
"and",
"a",
"CASA",
"polarization",
"code",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/closures.py#L168-L181 |
45,426 | pkgw/pwkit | pwkit/environments/casa/closures.py | ClosureCalculator._finish_timeslot | def _finish_timeslot (self):
"""We have loaded in all of the visibilities in one timeslot. We can now
compute the phase closure triples.
XXX: we should only process independent triples. Are we???
"""
for fpol, aps in self.ap_by_fpol.items ():
aps = sorted (aps)
... | python | def _finish_timeslot (self):
"""We have loaded in all of the visibilities in one timeslot. We can now
compute the phase closure triples.
XXX: we should only process independent triples. Are we???
"""
for fpol, aps in self.ap_by_fpol.items ():
aps = sorted (aps)
... | [
"def",
"_finish_timeslot",
"(",
"self",
")",
":",
"for",
"fpol",
",",
"aps",
"in",
"self",
".",
"ap_by_fpol",
".",
"items",
"(",
")",
":",
"aps",
"=",
"sorted",
"(",
"aps",
")",
"nap",
"=",
"len",
"(",
"aps",
")",
"for",
"i1",
",",
"ap1",
"in",
... | We have loaded in all of the visibilities in one timeslot. We can now
compute the phase closure triples.
XXX: we should only process independent triples. Are we??? | [
"We",
"have",
"loaded",
"in",
"all",
"of",
"the",
"visibilities",
"in",
"one",
"timeslot",
".",
"We",
"can",
"now",
"compute",
"the",
"phase",
"closure",
"triples",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/closures.py#L699-L750 |
45,427 | pkgw/pwkit | pwkit/environments/casa/closures.py | ClosureCalculator._process_sample | def _process_sample (self, ap1, ap2, ap3, triple, tflags):
"""We have computed one independent phase closure triple in one timeslot.
"""
# Frequency-resolved:
np.divide (triple, np.abs (triple), triple)
phase = np.angle (triple)
self.ap_spec_stats_by_ddid[self.cur_ddid]... | python | def _process_sample (self, ap1, ap2, ap3, triple, tflags):
"""We have computed one independent phase closure triple in one timeslot.
"""
# Frequency-resolved:
np.divide (triple, np.abs (triple), triple)
phase = np.angle (triple)
self.ap_spec_stats_by_ddid[self.cur_ddid]... | [
"def",
"_process_sample",
"(",
"self",
",",
"ap1",
",",
"ap2",
",",
"ap3",
",",
"triple",
",",
"tflags",
")",
":",
"# Frequency-resolved:",
"np",
".",
"divide",
"(",
"triple",
",",
"np",
".",
"abs",
"(",
"triple",
")",
",",
"triple",
")",
"phase",
"=... | We have computed one independent phase closure triple in one timeslot. | [
"We",
"have",
"computed",
"one",
"independent",
"phase",
"closure",
"triple",
"in",
"one",
"timeslot",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/closures.py#L753-L780 |
45,428 | pkgw/pwkit | pwkit/phoenix.py | load_spectrum | def load_spectrum(path, smoothing=181, DF=-8.):
"""Load a Phoenix model atmosphere spectrum.
path : string
The file path to load.
smoothing : integer
Smoothing to apply. If None, do not smooth. If an integer, smooth with a
Hamming window. Otherwise, the variable is assumed to be a differe... | python | def load_spectrum(path, smoothing=181, DF=-8.):
"""Load a Phoenix model atmosphere spectrum.
path : string
The file path to load.
smoothing : integer
Smoothing to apply. If None, do not smooth. If an integer, smooth with a
Hamming window. Otherwise, the variable is assumed to be a differe... | [
"def",
"load_spectrum",
"(",
"path",
",",
"smoothing",
"=",
"181",
",",
"DF",
"=",
"-",
"8.",
")",
":",
"try",
":",
"ang",
",",
"lflam",
"=",
"np",
".",
"loadtxt",
"(",
"path",
",",
"usecols",
"=",
"(",
"0",
",",
"1",
")",
")",
".",
"T",
"exc... | Load a Phoenix model atmosphere spectrum.
path : string
The file path to load.
smoothing : integer
Smoothing to apply. If None, do not smooth. If an integer, smooth with a
Hamming window. Otherwise, the variable is assumed to be a different
smoothing window, and the data will be convolv... | [
"Load",
"a",
"Phoenix",
"model",
"atmosphere",
"spectrum",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/phoenix.py#L44-L103 |
45,429 | pkgw/pwkit | pwkit/ucd_physics.py | lbol_from_spt_dist_mag | def lbol_from_spt_dist_mag (sptnum, dist_pc, jmag, kmag, format='cgs'):
"""Estimate a UCD's bolometric luminosity given some basic parameters.
sptnum: the spectral type as a number; 8 -> M8; 10 -> L0 ; 20 -> T0
Valid values range between 0 and 30, ie M0 to Y0.
dist_pc: distance to the object in parse... | python | def lbol_from_spt_dist_mag (sptnum, dist_pc, jmag, kmag, format='cgs'):
"""Estimate a UCD's bolometric luminosity given some basic parameters.
sptnum: the spectral type as a number; 8 -> M8; 10 -> L0 ; 20 -> T0
Valid values range between 0 and 30, ie M0 to Y0.
dist_pc: distance to the object in parse... | [
"def",
"lbol_from_spt_dist_mag",
"(",
"sptnum",
",",
"dist_pc",
",",
"jmag",
",",
"kmag",
",",
"format",
"=",
"'cgs'",
")",
":",
"bcj",
"=",
"bcj_from_spt",
"(",
"sptnum",
")",
"bck",
"=",
"bck_from_spt",
"(",
"sptnum",
")",
"n",
"=",
"np",
".",
"zeros... | Estimate a UCD's bolometric luminosity given some basic parameters.
sptnum: the spectral type as a number; 8 -> M8; 10 -> L0 ; 20 -> T0
Valid values range between 0 and 30, ie M0 to Y0.
dist_pc: distance to the object in parsecs
jmag: object's J-band magnitude or NaN (*not* None) if unavailable
k... | [
"Estimate",
"a",
"UCD",
"s",
"bolometric",
"luminosity",
"given",
"some",
"basic",
"parameters",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ucd_physics.py#L129-L167 |
45,430 | pkgw/pwkit | pwkit/parallel.py | InterruptiblePool.map | def map(self, func, iterable, chunksize=None):
"""Equivalent of `map` built-in, without swallowing KeyboardInterrupt.
func
The function to apply to the items.
iterable
An iterable of items that will have `func` applied to them.
"""
# The key magic is that we... | python | def map(self, func, iterable, chunksize=None):
"""Equivalent of `map` built-in, without swallowing KeyboardInterrupt.
func
The function to apply to the items.
iterable
An iterable of items that will have `func` applied to them.
"""
# The key magic is that we... | [
"def",
"map",
"(",
"self",
",",
"func",
",",
"iterable",
",",
"chunksize",
"=",
"None",
")",
":",
"# The key magic is that we must call r.get() with a timeout, because a",
"# Condition.wait() without a timeout swallows KeyboardInterrupts.",
"r",
"=",
"self",
".",
"map_async",... | Equivalent of `map` built-in, without swallowing KeyboardInterrupt.
func
The function to apply to the items.
iterable
An iterable of items that will have `func` applied to them. | [
"Equivalent",
"of",
"map",
"built",
"-",
"in",
"without",
"swallowing",
"KeyboardInterrupt",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/parallel.py#L107-L128 |
45,431 | pkgw/pwkit | pwkit/astutil.py | fmthours | def fmthours (radians, norm='wrap', precision=3, seps='::'):
"""Format an angle as sexagesimal hours in a string.
Arguments are:
radians
The angle, in radians.
norm (default "wrap")
The normalization mode, used for angles outside of the standard range
of 0 to 2π. If "none", the value... | python | def fmthours (radians, norm='wrap', precision=3, seps='::'):
"""Format an angle as sexagesimal hours in a string.
Arguments are:
radians
The angle, in radians.
norm (default "wrap")
The normalization mode, used for angles outside of the standard range
of 0 to 2π. If "none", the value... | [
"def",
"fmthours",
"(",
"radians",
",",
"norm",
"=",
"'wrap'",
",",
"precision",
"=",
"3",
",",
"seps",
"=",
"'::'",
")",
":",
"return",
"_fmtsexagesimal",
"(",
"radians",
"*",
"R2H",
",",
"norm",
",",
"24",
",",
"seps",
",",
"precision",
"=",
"preci... | Format an angle as sexagesimal hours in a string.
Arguments are:
radians
The angle, in radians.
norm (default "wrap")
The normalization mode, used for angles outside of the standard range
of 0 to 2π. If "none", the value is formatted ignoring any potential
problems. If "wrap", it i... | [
"Format",
"an",
"angle",
"as",
"sexagesimal",
"hours",
"in",
"a",
"string",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L114-L138 |
45,432 | pkgw/pwkit | pwkit/astutil.py | fmtdeglon | def fmtdeglon (radians, norm='wrap', precision=2, seps='::'):
"""Format a longitudinal angle as sexagesimal degrees in a string.
Arguments are:
radians
The angle, in radians.
norm (default "wrap")
The normalization mode, used for angles outside of the standard range
of 0 to 2π. If "n... | python | def fmtdeglon (radians, norm='wrap', precision=2, seps='::'):
"""Format a longitudinal angle as sexagesimal degrees in a string.
Arguments are:
radians
The angle, in radians.
norm (default "wrap")
The normalization mode, used for angles outside of the standard range
of 0 to 2π. If "n... | [
"def",
"fmtdeglon",
"(",
"radians",
",",
"norm",
"=",
"'wrap'",
",",
"precision",
"=",
"2",
",",
"seps",
"=",
"'::'",
")",
":",
"return",
"_fmtsexagesimal",
"(",
"radians",
"*",
"R2D",
",",
"norm",
",",
"360",
",",
"seps",
",",
"precision",
"=",
"pre... | Format a longitudinal angle as sexagesimal degrees in a string.
Arguments are:
radians
The angle, in radians.
norm (default "wrap")
The normalization mode, used for angles outside of the standard range
of 0 to 2π. If "none", the value is formatted ignoring any potential
problems. I... | [
"Format",
"a",
"longitudinal",
"angle",
"as",
"sexagesimal",
"degrees",
"in",
"a",
"string",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L141-L165 |
45,433 | pkgw/pwkit | pwkit/astutil.py | fmtdeglat | def fmtdeglat (radians, norm='raise', precision=2, seps='::'):
"""Format a latitudinal angle as sexagesimal degrees in a string.
Arguments are:
radians
The angle, in radians.
norm (default "raise")
The normalization mode, used for angles outside of the standard range
of -π/2 to π/2. ... | python | def fmtdeglat (radians, norm='raise', precision=2, seps='::'):
"""Format a latitudinal angle as sexagesimal degrees in a string.
Arguments are:
radians
The angle, in radians.
norm (default "raise")
The normalization mode, used for angles outside of the standard range
of -π/2 to π/2. ... | [
"def",
"fmtdeglat",
"(",
"radians",
",",
"norm",
"=",
"'raise'",
",",
"precision",
"=",
"2",
",",
"seps",
"=",
"'::'",
")",
":",
"if",
"norm",
"==",
"'none'",
":",
"pass",
"elif",
"norm",
"==",
"'raise'",
":",
"if",
"radians",
">",
"halfpi",
"or",
... | Format a latitudinal angle as sexagesimal degrees in a string.
Arguments are:
radians
The angle, in radians.
norm (default "raise")
The normalization mode, used for angles outside of the standard range
of -π/2 to π/2. If "none", the value is formatted ignoring any potential
problem... | [
"Format",
"a",
"latitudinal",
"angle",
"as",
"sexagesimal",
"degrees",
"in",
"a",
"string",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L168-L247 |
45,434 | pkgw/pwkit | pwkit/astutil.py | fmtradec | def fmtradec (rarad, decrad, precision=2, raseps='::', decseps='::', intersep=' '):
"""Format equatorial coordinates in a single sexagesimal string.
Returns a string of the RA/lon coordinate, formatted as sexagesimal hours,
then *intersep*, then the Dec/lat coordinate, formatted as degrees. This
yields... | python | def fmtradec (rarad, decrad, precision=2, raseps='::', decseps='::', intersep=' '):
"""Format equatorial coordinates in a single sexagesimal string.
Returns a string of the RA/lon coordinate, formatted as sexagesimal hours,
then *intersep*, then the Dec/lat coordinate, formatted as degrees. This
yields... | [
"def",
"fmtradec",
"(",
"rarad",
",",
"decrad",
",",
"precision",
"=",
"2",
",",
"raseps",
"=",
"'::'",
",",
"decseps",
"=",
"'::'",
",",
"intersep",
"=",
"' '",
")",
":",
"return",
"(",
"fmthours",
"(",
"rarad",
",",
"precision",
"=",
"precision",
"... | Format equatorial coordinates in a single sexagesimal string.
Returns a string of the RA/lon coordinate, formatted as sexagesimal hours,
then *intersep*, then the Dec/lat coordinate, formatted as degrees. This
yields something like "12:34:56.78 -01:23:45.6". Arguments are:
rarad
The right ascens... | [
"Format",
"equatorial",
"coordinates",
"in",
"a",
"single",
"sexagesimal",
"string",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L250-L285 |
45,435 | pkgw/pwkit | pwkit/astutil.py | parsehours | def parsehours (hrstr):
"""Parse a string formatted as sexagesimal hours into an angle.
This function converts a textual representation of an angle, measured in
hours, into a floating point value measured in radians. The format of
*hrstr* is very limited: it may not have leading or trailing whitespace,... | python | def parsehours (hrstr):
"""Parse a string formatted as sexagesimal hours into an angle.
This function converts a textual representation of an angle, measured in
hours, into a floating point value measured in radians. The format of
*hrstr* is very limited: it may not have leading or trailing whitespace,... | [
"def",
"parsehours",
"(",
"hrstr",
")",
":",
"hr",
"=",
"_parsesexagesimal",
"(",
"hrstr",
",",
"'hours'",
",",
"False",
")",
"if",
"hr",
">=",
"24",
":",
"raise",
"ValueError",
"(",
"'illegal hour specification: '",
"+",
"hrstr",
")",
"return",
"hr",
"*",... | Parse a string formatted as sexagesimal hours into an angle.
This function converts a textual representation of an angle, measured in
hours, into a floating point value measured in radians. The format of
*hrstr* is very limited: it may not have leading or trailing whitespace,
and the components of the ... | [
"Parse",
"a",
"string",
"formatted",
"as",
"sexagesimal",
"hours",
"into",
"an",
"angle",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L319-L335 |
45,436 | pkgw/pwkit | pwkit/astutil.py | parsedeglat | def parsedeglat (latstr):
"""Parse a latitude formatted as sexagesimal degrees into an angle.
This function converts a textual representation of a latitude, measured in
degrees, into a floating point value measured in radians. The format of
*latstr* is very limited: it may not have leading or trailing ... | python | def parsedeglat (latstr):
"""Parse a latitude formatted as sexagesimal degrees into an angle.
This function converts a textual representation of a latitude, measured in
degrees, into a floating point value measured in radians. The format of
*latstr* is very limited: it may not have leading or trailing ... | [
"def",
"parsedeglat",
"(",
"latstr",
")",
":",
"deg",
"=",
"_parsesexagesimal",
"(",
"latstr",
",",
"'latitude'",
",",
"True",
")",
"if",
"abs",
"(",
"deg",
")",
">",
"90",
":",
"raise",
"ValueError",
"(",
"'illegal latitude specification: '",
"+",
"latstr",... | Parse a latitude formatted as sexagesimal degrees into an angle.
This function converts a textual representation of a latitude, measured in
degrees, into a floating point value measured in radians. The format of
*latstr* is very limited: it may not have leading or trailing whitespace,
and the component... | [
"Parse",
"a",
"latitude",
"formatted",
"as",
"sexagesimal",
"degrees",
"into",
"an",
"angle",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L338-L354 |
45,437 | pkgw/pwkit | pwkit/astutil.py | sphdist | def sphdist (lat1, lon1, lat2, lon2):
"""Calculate the distance between two locations on a sphere.
lat1
The latitude of the first location.
lon1
The longitude of the first location.
lat2
The latitude of the second location.
lon2
The longitude of the second location.
Ret... | python | def sphdist (lat1, lon1, lat2, lon2):
"""Calculate the distance between two locations on a sphere.
lat1
The latitude of the first location.
lon1
The longitude of the first location.
lat2
The latitude of the second location.
lon2
The longitude of the second location.
Ret... | [
"def",
"sphdist",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
":",
"cd",
"=",
"np",
".",
"cos",
"(",
"lon2",
"-",
"lon1",
")",
"sd",
"=",
"np",
".",
"sin",
"(",
"lon2",
"-",
"lon1",
")",
"c2",
"=",
"np",
".",
"cos",
"(",
"lat2"... | Calculate the distance between two locations on a sphere.
lat1
The latitude of the first location.
lon1
The longitude of the first location.
lat2
The latitude of the second location.
lon2
The longitude of the second location.
Returns the separation in radians. All arguments... | [
"Calculate",
"the",
"distance",
"between",
"two",
"locations",
"on",
"a",
"sphere",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L376-L408 |
45,438 | pkgw/pwkit | pwkit/astutil.py | sphbear | def sphbear (lat1, lon1, lat2, lon2, tol=1e-15):
"""Calculate the bearing between two locations on a sphere.
lat1
The latitude of the first location.
lon1
The longitude of the first location.
lat2
The latitude of the second location.
lon2
The longitude of the second location... | python | def sphbear (lat1, lon1, lat2, lon2, tol=1e-15):
"""Calculate the bearing between two locations on a sphere.
lat1
The latitude of the first location.
lon1
The longitude of the first location.
lat2
The latitude of the second location.
lon2
The longitude of the second location... | [
"def",
"sphbear",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
",",
"tol",
"=",
"1e-15",
")",
":",
"# cross product on outer axis:",
"ocross",
"=",
"lambda",
"a",
",",
"b",
":",
"np",
".",
"cross",
"(",
"a",
",",
"b",
",",
"axisa",
"=",
"0",... | Calculate the bearing between two locations on a sphere.
lat1
The latitude of the first location.
lon1
The longitude of the first location.
lat2
The latitude of the second location.
lon2
The longitude of the second location.
tol
Tolerance for checking proximity to pole... | [
"Calculate",
"the",
"bearing",
"between",
"two",
"locations",
"on",
"a",
"sphere",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L412-L471 |
45,439 | pkgw/pwkit | pwkit/astutil.py | sphofs | def sphofs (lat1, lon1, r, pa, tol=1e-2, rmax=None):
"""Offset from one location on the sphere to another.
This function is given a start location, expressed as a latitude and
longitude, a distance to offset, and a direction to offset (expressed as a
bearing, AKA position angle). It uses these to compu... | python | def sphofs (lat1, lon1, r, pa, tol=1e-2, rmax=None):
"""Offset from one location on the sphere to another.
This function is given a start location, expressed as a latitude and
longitude, a distance to offset, and a direction to offset (expressed as a
bearing, AKA position angle). It uses these to compu... | [
"def",
"sphofs",
"(",
"lat1",
",",
"lon1",
",",
"r",
",",
"pa",
",",
"tol",
"=",
"1e-2",
",",
"rmax",
"=",
"None",
")",
":",
"if",
"rmax",
"is",
"not",
"None",
"and",
"np",
".",
"abs",
"(",
"r",
")",
">",
"rmax",
":",
"raise",
"ValueError",
"... | Offset from one location on the sphere to another.
This function is given a start location, expressed as a latitude and
longitude, a distance to offset, and a direction to offset (expressed as a
bearing, AKA position angle). It uses these to compute a final location.
This function mirrors :func:`sphdis... | [
"Offset",
"from",
"one",
"location",
"on",
"the",
"sphere",
"to",
"another",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L474-L543 |
45,440 | pkgw/pwkit | pwkit/astutil.py | parang | def parang (hourangle, declination, latitude):
"""Calculate the parallactic angle of a sky position.
This computes the parallactic angle of a sky position expressed in terms
of an hour angle and declination. Arguments:
hourangle
The hour angle of the location on the sky.
declination
Th... | python | def parang (hourangle, declination, latitude):
"""Calculate the parallactic angle of a sky position.
This computes the parallactic angle of a sky position expressed in terms
of an hour angle and declination. Arguments:
hourangle
The hour angle of the location on the sky.
declination
Th... | [
"def",
"parang",
"(",
"hourangle",
",",
"declination",
",",
"latitude",
")",
":",
"return",
"-",
"np",
".",
"arctan2",
"(",
"-",
"np",
".",
"sin",
"(",
"hourangle",
")",
",",
"np",
".",
"cos",
"(",
"declination",
")",
"*",
"np",
".",
"tan",
"(",
... | Calculate the parallactic angle of a sky position.
This computes the parallactic angle of a sky position expressed in terms
of an hour angle and declination. Arguments:
hourangle
The hour angle of the location on the sky.
declination
The declination of the location on the sky.
latitude... | [
"Calculate",
"the",
"parallactic",
"angle",
"of",
"a",
"sky",
"position",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L549-L568 |
45,441 | pkgw/pwkit | pwkit/astutil.py | gaussian_convolve | def gaussian_convolve (maj1, min1, pa1, maj2, min2, pa2):
"""Convolve two Gaussians analytically.
Given the shapes of two 2-dimensional Gaussians, this function returns
the shape of their convolution.
Arguments:
maj1
Major axis of input Gaussian 1.
min1
Minor axis of input Gaussia... | python | def gaussian_convolve (maj1, min1, pa1, maj2, min2, pa2):
"""Convolve two Gaussians analytically.
Given the shapes of two 2-dimensional Gaussians, this function returns
the shape of their convolution.
Arguments:
maj1
Major axis of input Gaussian 1.
min1
Minor axis of input Gaussia... | [
"def",
"gaussian_convolve",
"(",
"maj1",
",",
"min1",
",",
"pa1",
",",
"maj2",
",",
"min2",
",",
"pa2",
")",
":",
"c1",
"=",
"np",
".",
"cos",
"(",
"pa1",
")",
"s1",
"=",
"np",
".",
"sin",
"(",
"pa1",
")",
"c2",
"=",
"np",
".",
"cos",
"(",
... | Convolve two Gaussians analytically.
Given the shapes of two 2-dimensional Gaussians, this function returns
the shape of their convolution.
Arguments:
maj1
Major axis of input Gaussian 1.
min1
Minor axis of input Gaussian 1.
pa1
Orientation angle of input Gaussian 1, in radi... | [
"Convolve",
"two",
"Gaussians",
"analytically",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L573-L624 |
45,442 | pkgw/pwkit | pwkit/astutil.py | gaussian_deconvolve | def gaussian_deconvolve (smaj, smin, spa, bmaj, bmin, bpa):
"""Deconvolve two Gaussians analytically.
Given the shapes of 2-dimensional “source” and “beam” Gaussians, this
returns a deconvolved “result” Gaussian such that the convolution of
“beam” and “result” is “source”.
Arguments:
smaj
... | python | def gaussian_deconvolve (smaj, smin, spa, bmaj, bmin, bpa):
"""Deconvolve two Gaussians analytically.
Given the shapes of 2-dimensional “source” and “beam” Gaussians, this
returns a deconvolved “result” Gaussian such that the convolution of
“beam” and “result” is “source”.
Arguments:
smaj
... | [
"def",
"gaussian_deconvolve",
"(",
"smaj",
",",
"smin",
",",
"spa",
",",
"bmaj",
",",
"bmin",
",",
"bpa",
")",
":",
"# I've added extra code to ensure ``smaj >= bmaj``, ``smin >= bmin``, and",
"# increased the coefficient in front of \"limit\" from 0.1 to 0.5. Feel a",
"# little ... | Deconvolve two Gaussians analytically.
Given the shapes of 2-dimensional “source” and “beam” Gaussians, this
returns a deconvolved “result” Gaussian such that the convolution of
“beam” and “result” is “source”.
Arguments:
smaj
Major axis of source Gaussian.
smin
Minor axis of sour... | [
"Deconvolve",
"two",
"Gaussians",
"analytically",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L627-L710 |
45,443 | pkgw/pwkit | pwkit/astutil.py | load_skyfield_data | def load_skyfield_data():
"""Load data files used in Skyfield. This will download files from the
internet if they haven't been downloaded before.
Skyfield downloads files to the current directory by default, which is not
ideal. Here we abuse astropy and use its cache directory to cache the data
fil... | python | def load_skyfield_data():
"""Load data files used in Skyfield. This will download files from the
internet if they haven't been downloaded before.
Skyfield downloads files to the current directory by default, which is not
ideal. Here we abuse astropy and use its cache directory to cache the data
fil... | [
"def",
"load_skyfield_data",
"(",
")",
":",
"import",
"os",
".",
"path",
"from",
"astropy",
".",
"config",
"import",
"paths",
"from",
"skyfield",
".",
"api",
"import",
"Loader",
"cache_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"paths",
".",
"get_ca... | Load data files used in Skyfield. This will download files from the
internet if they haven't been downloaded before.
Skyfield downloads files to the current directory by default, which is not
ideal. Here we abuse astropy and use its cache directory to cache the data
files per-user. If we start download... | [
"Load",
"data",
"files",
"used",
"in",
"Skyfield",
".",
"This",
"will",
"download",
"files",
"from",
"the",
"internet",
"if",
"they",
"haven",
"t",
"been",
"downloaded",
"before",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L718-L742 |
45,444 | pkgw/pwkit | pwkit/astutil.py | get_2mass_epoch | def get_2mass_epoch (tmra, tmdec, debug=False):
"""Given a 2MASS position, look up the epoch when it was observed.
This function uses the CDS Vizier web service to look up information in
the 2MASS point source database. Arguments are:
tmra
The source's J2000 right ascension, in radians.
tmde... | python | def get_2mass_epoch (tmra, tmdec, debug=False):
"""Given a 2MASS position, look up the epoch when it was observed.
This function uses the CDS Vizier web service to look up information in
the 2MASS point source database. Arguments are:
tmra
The source's J2000 right ascension, in radians.
tmde... | [
"def",
"get_2mass_epoch",
"(",
"tmra",
",",
"tmdec",
",",
"debug",
"=",
"False",
")",
":",
"import",
"codecs",
"try",
":",
"from",
"urllib",
".",
"request",
"import",
"urlopen",
"except",
"ImportError",
":",
"from",
"urllib2",
"import",
"urlopen",
"postdata"... | Given a 2MASS position, look up the epoch when it was observed.
This function uses the CDS Vizier web service to look up information in
the 2MASS point source database. Arguments are:
tmra
The source's J2000 right ascension, in radians.
tmdec
The source's J2000 declination, in radians.
... | [
"Given",
"a",
"2MASS",
"position",
"look",
"up",
"the",
"epoch",
"when",
"it",
"was",
"observed",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L797-L842 |
45,445 | pkgw/pwkit | pwkit/astutil.py | AstrometryInfo.verify | def verify (self, complain=True):
"""Validate that the attributes are self-consistent.
This function does some basic checks of the object attributes to
ensure that astrometric calculations can legally be performed. If the
*complain* keyword is true, messages may be printed to
:d... | python | def verify (self, complain=True):
"""Validate that the attributes are self-consistent.
This function does some basic checks of the object attributes to
ensure that astrometric calculations can legally be performed. If the
*complain* keyword is true, messages may be printed to
:d... | [
"def",
"verify",
"(",
"self",
",",
"complain",
"=",
"True",
")",
":",
"import",
"sys",
"if",
"self",
".",
"ra",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'AstrometryInfo missing \"ra\"'",
")",
"if",
"self",
".",
"dec",
"is",
"None",
":",
"raise",
... | Validate that the attributes are self-consistent.
This function does some basic checks of the object attributes to
ensure that astrometric calculations can legally be performed. If the
*complain* keyword is true, messages may be printed to
:data:`sys.stderr` if non-fatal issues are enco... | [
"Validate",
"that",
"the",
"attributes",
"are",
"self",
"-",
"consistent",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L994-L1066 |
45,446 | pkgw/pwkit | pwkit/astutil.py | AstrometryInfo.fill_from_simbad | def fill_from_simbad (self, ident, debug=False):
"""Fill in astrometric information using the Simbad web service.
This uses the CDS Simbad web service to look up astrometric
information for the source name *ident* and fills in attributes
appropriately. Values from Simbad are not always ... | python | def fill_from_simbad (self, ident, debug=False):
"""Fill in astrometric information using the Simbad web service.
This uses the CDS Simbad web service to look up astrometric
information for the source name *ident* and fills in attributes
appropriately. Values from Simbad are not always ... | [
"def",
"fill_from_simbad",
"(",
"self",
",",
"ident",
",",
"debug",
"=",
"False",
")",
":",
"info",
"=",
"get_simbad_astrometry_info",
"(",
"ident",
",",
"debug",
"=",
"debug",
")",
"posref",
"=",
"'unknown'",
"for",
"k",
",",
"v",
"in",
"six",
".",
"i... | Fill in astrometric information using the Simbad web service.
This uses the CDS Simbad web service to look up astrometric
information for the source name *ident* and fills in attributes
appropriately. Values from Simbad are not always reliable.
Returns *self*. | [
"Fill",
"in",
"astrometric",
"information",
"using",
"the",
"Simbad",
"web",
"service",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L1242-L1300 |
45,447 | pkgw/pwkit | pwkit/astutil.py | AstrometryInfo.fill_from_allwise | def fill_from_allwise (self, ident, catalog_ident='II/328/allwise'):
"""Fill in astrometric information from the AllWISE catalog using Astroquery.
This uses the :mod:`astroquery` module to query the AllWISE
(2013wise.rept....1C) source catalog through the Vizier
(2000A&AS..143...23O) we... | python | def fill_from_allwise (self, ident, catalog_ident='II/328/allwise'):
"""Fill in astrometric information from the AllWISE catalog using Astroquery.
This uses the :mod:`astroquery` module to query the AllWISE
(2013wise.rept....1C) source catalog through the Vizier
(2000A&AS..143...23O) we... | [
"def",
"fill_from_allwise",
"(",
"self",
",",
"ident",
",",
"catalog_ident",
"=",
"'II/328/allwise'",
")",
":",
"from",
"astroquery",
".",
"vizier",
"import",
"Vizier",
"import",
"numpy",
".",
"ma",
".",
"core",
"as",
"ma_core",
"# We should match exactly one tabl... | Fill in astrometric information from the AllWISE catalog using Astroquery.
This uses the :mod:`astroquery` module to query the AllWISE
(2013wise.rept....1C) source catalog through the Vizier
(2000A&AS..143...23O) web service. It then fills in the instance with
the relevant information. ... | [
"Fill",
"in",
"astrometric",
"information",
"from",
"the",
"AllWISE",
"catalog",
"using",
"Astroquery",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astutil.py#L1303-L1383 |
45,448 | pkgw/pwkit | pwkit/cli/__init__.py | backtrace_on_usr1 | def backtrace_on_usr1 ():
"""Install a signal handler such that this program prints a Python traceback
upon receipt of SIGUSR1. This could be useful for checking that
long-running programs are behaving properly, or for discovering where an
infinite loop is occurring.
Note, however, that the Python ... | python | def backtrace_on_usr1 ():
"""Install a signal handler such that this program prints a Python traceback
upon receipt of SIGUSR1. This could be useful for checking that
long-running programs are behaving properly, or for discovering where an
infinite loop is occurring.
Note, however, that the Python ... | [
"def",
"backtrace_on_usr1",
"(",
")",
":",
"import",
"signal",
"try",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGUSR1",
",",
"_print_backtrace_signal_handler",
")",
"except",
"Exception",
"as",
"e",
":",
"warn",
"(",
"'failed to set up Python backtraces... | Install a signal handler such that this program prints a Python traceback
upon receipt of SIGUSR1. This could be useful for checking that
long-running programs are behaving properly, or for discovering where an
infinite loop is occurring.
Note, however, that the Python interpreter does not invoke Pytho... | [
"Install",
"a",
"signal",
"handler",
"such",
"that",
"this",
"program",
"prints",
"a",
"Python",
"traceback",
"upon",
"receipt",
"of",
"SIGUSR1",
".",
"This",
"could",
"be",
"useful",
"for",
"checking",
"that",
"long",
"-",
"running",
"programs",
"are",
"beh... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/__init__.py#L157-L174 |
45,449 | pkgw/pwkit | pwkit/cli/__init__.py | fork_detached_process | def fork_detached_process ():
"""Fork this process, creating a subprocess detached from the current context.
Returns a :class:`pwkit.Holder` instance with information about what
happened. Its fields are:
whoami
A string, either "original" or "forked" depending on which process we are.
pipe
... | python | def fork_detached_process ():
"""Fork this process, creating a subprocess detached from the current context.
Returns a :class:`pwkit.Holder` instance with information about what
happened. Its fields are:
whoami
A string, either "original" or "forked" depending on which process we are.
pipe
... | [
"def",
"fork_detached_process",
"(",
")",
":",
"import",
"os",
",",
"struct",
"from",
".",
".",
"import",
"Holder",
"payload",
"=",
"struct",
".",
"Struct",
"(",
"'L'",
")",
"info",
"=",
"Holder",
"(",
")",
"readfd",
",",
"writefd",
"=",
"os",
".",
"... | Fork this process, creating a subprocess detached from the current context.
Returns a :class:`pwkit.Holder` instance with information about what
happened. Its fields are:
whoami
A string, either "original" or "forked" depending on which process we are.
pipe
An open binary file descriptor. ... | [
"Fork",
"this",
"process",
"creating",
"a",
"subprocess",
"detached",
"from",
"the",
"current",
"context",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/__init__.py#L261-L345 |
45,450 | pkgw/pwkit | pwkit/cli/__init__.py | pop_option | def pop_option (ident, argv=None):
"""A lame routine for grabbing command-line arguments. Returns a boolean
indicating whether the option was present. If it was, it's removed from
the argument string. Because of the lame behavior, options can't be
combined, and non-boolean options aren't supported. Oper... | python | def pop_option (ident, argv=None):
"""A lame routine for grabbing command-line arguments. Returns a boolean
indicating whether the option was present. If it was, it's removed from
the argument string. Because of the lame behavior, options can't be
combined, and non-boolean options aren't supported. Oper... | [
"def",
"pop_option",
"(",
"ident",
",",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"from",
"sys",
"import",
"argv",
"if",
"len",
"(",
"ident",
")",
"==",
"1",
":",
"ident",
"=",
"'-'",
"+",
"ident",
"else",
":",
"ident",
"=",... | A lame routine for grabbing command-line arguments. Returns a boolean
indicating whether the option was present. If it was, it's removed from
the argument string. Because of the lame behavior, options can't be
combined, and non-boolean options aren't supported. Operates on sys.argv
by default.
Note... | [
"A",
"lame",
"routine",
"for",
"grabbing",
"command",
"-",
"line",
"arguments",
".",
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"option",
"was",
"present",
".",
"If",
"it",
"was",
"it",
"s",
"removed",
"from",
"the",
"argument",
"string",
"... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/__init__.py#L350-L372 |
45,451 | pkgw/pwkit | pwkit/cli/__init__.py | show_usage | def show_usage (docstring, short, stream, exitcode):
"""Print program usage information and exit.
:arg str docstring: the program help text
This function just prints *docstring* and exits. In most cases, the
function :func:`check_usage` should be used: it automatically checks
:data:`sys.argv` for ... | python | def show_usage (docstring, short, stream, exitcode):
"""Print program usage information and exit.
:arg str docstring: the program help text
This function just prints *docstring* and exits. In most cases, the
function :func:`check_usage` should be used: it automatically checks
:data:`sys.argv` for ... | [
"def",
"show_usage",
"(",
"docstring",
",",
"short",
",",
"stream",
",",
"exitcode",
")",
":",
"if",
"stream",
"is",
"None",
":",
"from",
"sys",
"import",
"stdout",
"as",
"stream",
"if",
"not",
"short",
":",
"print",
"(",
"'Usage:'",
",",
"docstring",
... | Print program usage information and exit.
:arg str docstring: the program help text
This function just prints *docstring* and exits. In most cases, the
function :func:`check_usage` should be used: it automatically checks
:data:`sys.argv` for a sole "-h" or "--help" argument and invokes this
functi... | [
"Print",
"program",
"usage",
"information",
"and",
"exit",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/__init__.py#L375-L410 |
45,452 | pkgw/pwkit | pwkit/cli/__init__.py | wrong_usage | def wrong_usage (docstring, *rest):
"""Print a message indicating invalid command-line arguments and exit with an
error code.
:arg str docstring: the program help text
:arg rest: an optional specific error message
This function is intended for small programs launched from the command
line. The... | python | def wrong_usage (docstring, *rest):
"""Print a message indicating invalid command-line arguments and exit with an
error code.
:arg str docstring: the program help text
:arg rest: an optional specific error message
This function is intended for small programs launched from the command
line. The... | [
"def",
"wrong_usage",
"(",
"docstring",
",",
"*",
"rest",
")",
":",
"intext",
"=",
"False",
"if",
"len",
"(",
"rest",
")",
"==",
"0",
":",
"detail",
"=",
"'invalid command-line arguments'",
"elif",
"len",
"(",
"rest",
")",
"==",
"1",
":",
"detail",
"="... | Print a message indicating invalid command-line arguments and exit with an
error code.
:arg str docstring: the program help text
:arg rest: an optional specific error message
This function is intended for small programs launched from the command
line. The intention is for the program help informat... | [
"Print",
"a",
"message",
"indicating",
"invalid",
"command",
"-",
"line",
"arguments",
"and",
"exit",
"with",
"an",
"error",
"code",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/__init__.py#L450-L500 |
45,453 | pkgw/pwkit | pwkit/cli/__init__.py | _InterruptSignalPropagator.excepthook | def excepthook (self, etype, evalue, etb):
"""Handle an uncaught exception. We always forward the exception on to
whatever `sys.excepthook` was present upon setup. However, if the
exception is a KeyboardInterrupt, we additionally kill ourselves with
an uncaught SIGINT, so that invoking p... | python | def excepthook (self, etype, evalue, etb):
"""Handle an uncaught exception. We always forward the exception on to
whatever `sys.excepthook` was present upon setup. However, if the
exception is a KeyboardInterrupt, we additionally kill ourselves with
an uncaught SIGINT, so that invoking p... | [
"def",
"excepthook",
"(",
"self",
",",
"etype",
",",
"evalue",
",",
"etb",
")",
":",
"self",
".",
"inner_excepthook",
"(",
"etype",
",",
"evalue",
",",
"etb",
")",
"if",
"issubclass",
"(",
"etype",
",",
"KeyboardInterrupt",
")",
":",
"# Don't try this at h... | Handle an uncaught exception. We always forward the exception on to
whatever `sys.excepthook` was present upon setup. However, if the
exception is a KeyboardInterrupt, we additionally kill ourselves with
an uncaught SIGINT, so that invoking programs know what happened. | [
"Handle",
"an",
"uncaught",
"exception",
".",
"We",
"always",
"forward",
"the",
"exception",
"on",
"to",
"whatever",
"sys",
".",
"excepthook",
"was",
"present",
"upon",
"setup",
".",
"However",
"if",
"the",
"exception",
"is",
"a",
"KeyboardInterrupt",
"we",
... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/__init__.py#L122-L136 |
45,454 | pkgw/pwkit | pwkit/dulk_models.py | calc_nu_b | def calc_nu_b(b):
"""Calculate the cyclotron frequency in Hz given a magnetic field strength in Gauss.
This is in cycles per second not radians per second; i.e. there is a 2π in
the denominator: ν_B = e B / (2π m_e c)
"""
return cgs.e * b / (2 * cgs.pi * cgs.me * cgs.c) | python | def calc_nu_b(b):
"""Calculate the cyclotron frequency in Hz given a magnetic field strength in Gauss.
This is in cycles per second not radians per second; i.e. there is a 2π in
the denominator: ν_B = e B / (2π m_e c)
"""
return cgs.e * b / (2 * cgs.pi * cgs.me * cgs.c) | [
"def",
"calc_nu_b",
"(",
"b",
")",
":",
"return",
"cgs",
".",
"e",
"*",
"b",
"/",
"(",
"2",
"*",
"cgs",
".",
"pi",
"*",
"cgs",
".",
"me",
"*",
"cgs",
".",
"c",
")"
] | Calculate the cyclotron frequency in Hz given a magnetic field strength in Gauss.
This is in cycles per second not radians per second; i.e. there is a 2π in
the denominator: ν_B = e B / (2π m_e c) | [
"Calculate",
"the",
"cyclotron",
"frequency",
"in",
"Hz",
"given",
"a",
"magnetic",
"field",
"strength",
"in",
"Gauss",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/dulk_models.py#L41-L48 |
45,455 | pkgw/pwkit | pwkit/dulk_models.py | calc_freefree_snu_ujy | def calc_freefree_snu_ujy(ne, t, width, elongation, dist, ghz):
"""Calculate a flux density from pure free-free emission.
"""
hz = ghz * 1e9
eta = calc_freefree_eta(ne, t, hz)
kappa = calc_freefree_kappa(ne, t, hz)
snu = calc_snu(eta, kappa, width, elongation, dist)
ujy = snu * cgs.jypercgs... | python | def calc_freefree_snu_ujy(ne, t, width, elongation, dist, ghz):
"""Calculate a flux density from pure free-free emission.
"""
hz = ghz * 1e9
eta = calc_freefree_eta(ne, t, hz)
kappa = calc_freefree_kappa(ne, t, hz)
snu = calc_snu(eta, kappa, width, elongation, dist)
ujy = snu * cgs.jypercgs... | [
"def",
"calc_freefree_snu_ujy",
"(",
"ne",
",",
"t",
",",
"width",
",",
"elongation",
",",
"dist",
",",
"ghz",
")",
":",
"hz",
"=",
"ghz",
"*",
"1e9",
"eta",
"=",
"calc_freefree_eta",
"(",
"ne",
",",
"t",
",",
"hz",
")",
"kappa",
"=",
"calc_freefree_... | Calculate a flux density from pure free-free emission. | [
"Calculate",
"a",
"flux",
"density",
"from",
"pure",
"free",
"-",
"free",
"emission",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/dulk_models.py#L92-L101 |
45,456 | pkgw/pwkit | pwkit/environments/casa/tasks.py | concat | def concat(invises, outvis, timesort=False):
"""Concatenate visibility measurement sets.
invises (list of str)
Paths to the input measurement sets
outvis (str)
Path to the output measurement set.
timesort (boolean)
If true, sort the output in time after concatenation.
Example::
... | python | def concat(invises, outvis, timesort=False):
"""Concatenate visibility measurement sets.
invises (list of str)
Paths to the input measurement sets
outvis (str)
Path to the output measurement set.
timesort (boolean)
If true, sort the output in time after concatenation.
Example::
... | [
"def",
"concat",
"(",
"invises",
",",
"outvis",
",",
"timesort",
"=",
"False",
")",
":",
"tb",
"=",
"util",
".",
"tools",
".",
"table",
"(",
")",
"ms",
"=",
"util",
".",
"tools",
".",
"ms",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",... | Concatenate visibility measurement sets.
invises (list of str)
Paths to the input measurement sets
outvis (str)
Path to the output measurement set.
timesort (boolean)
If true, sort the output in time after concatenation.
Example::
from pwkit.environments.casa import tasks
... | [
"Concatenate",
"visibility",
"measurement",
"sets",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L658-L701 |
45,457 | pkgw/pwkit | pwkit/environments/casa/tasks.py | delcal | def delcal(mspath):
"""Delete the ``MODEL_DATA`` and ``CORRECTED_DATA`` columns from a measurement set.
mspath (str)
The path to the MS to modify
Example::
from pwkit.environments.casa import tasks
tasks.delcal('dataset.ms')
"""
wantremove = 'MODEL_DATA CORRECTED_DATA'.split()
... | python | def delcal(mspath):
"""Delete the ``MODEL_DATA`` and ``CORRECTED_DATA`` columns from a measurement set.
mspath (str)
The path to the MS to modify
Example::
from pwkit.environments.casa import tasks
tasks.delcal('dataset.ms')
"""
wantremove = 'MODEL_DATA CORRECTED_DATA'.split()
... | [
"def",
"delcal",
"(",
"mspath",
")",
":",
"wantremove",
"=",
"'MODEL_DATA CORRECTED_DATA'",
".",
"split",
"(",
")",
"tb",
"=",
"util",
".",
"tools",
".",
"table",
"(",
")",
"tb",
".",
"open",
"(",
"b",
"(",
"mspath",
")",
",",
"nomodify",
"=",
"False... | Delete the ``MODEL_DATA`` and ``CORRECTED_DATA`` columns from a measurement set.
mspath (str)
The path to the MS to modify
Example::
from pwkit.environments.casa import tasks
tasks.delcal('dataset.ms') | [
"Delete",
"the",
"MODEL_DATA",
"and",
"CORRECTED_DATA",
"columns",
"from",
"a",
"measurement",
"set",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L732-L758 |
45,458 | pkgw/pwkit | pwkit/environments/casa/tasks.py | delmod_cli | def delmod_cli(argv, alter_logger=True):
"""Command-line access to ``delmod`` functionality.
The ``delmod`` task deletes "on-the-fly" model information from a
Measurement Set. It is so easy to implement that a standalone
function is essentially unnecessary. Just write::
from pwkit.environments.c... | python | def delmod_cli(argv, alter_logger=True):
"""Command-line access to ``delmod`` functionality.
The ``delmod`` task deletes "on-the-fly" model information from a
Measurement Set. It is so easy to implement that a standalone
function is essentially unnecessary. Just write::
from pwkit.environments.c... | [
"def",
"delmod_cli",
"(",
"argv",
",",
"alter_logger",
"=",
"True",
")",
":",
"check_usage",
"(",
"delmod_doc",
",",
"argv",
",",
"usageifnoargs",
"=",
"True",
")",
"if",
"alter_logger",
":",
"util",
".",
"logger",
"(",
")",
"cb",
"=",
"util",
".",
"to... | Command-line access to ``delmod`` functionality.
The ``delmod`` task deletes "on-the-fly" model information from a
Measurement Set. It is so easy to implement that a standalone
function is essentially unnecessary. Just write::
from pwkit.environments.casa import util
cb = util.tools.calibrater... | [
"Command",
"-",
"line",
"access",
"to",
"delmod",
"functionality",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L788-L814 |
45,459 | pkgw/pwkit | pwkit/environments/casa/tasks.py | extractbpflags | def extractbpflags(calpath, deststream):
"""Make a flags file out of a bandpass calibration table
calpath (str)
The path to the bandpass calibration table
deststream (stream-like object, e.g. an opened file)
Where to write the flags data
Below is documentation written for the command-line ... | python | def extractbpflags(calpath, deststream):
"""Make a flags file out of a bandpass calibration table
calpath (str)
The path to the bandpass calibration table
deststream (stream-like object, e.g. an opened file)
Where to write the flags data
Below is documentation written for the command-line ... | [
"def",
"extractbpflags",
"(",
"calpath",
",",
"deststream",
")",
":",
"tb",
"=",
"util",
".",
"tools",
".",
"table",
"(",
")",
"tb",
".",
"open",
"(",
"b",
"(",
"os",
".",
"path",
".",
"join",
"(",
"calpath",
",",
"'ANTENNA'",
")",
")",
")",
"ant... | Make a flags file out of a bandpass calibration table
calpath (str)
The path to the bandpass calibration table
deststream (stream-like object, e.g. an opened file)
Where to write the flags data
Below is documentation written for the command-line interface to this
functionality: | [
"Make",
"a",
"flags",
"file",
"out",
"of",
"a",
"bandpass",
"calibration",
"table"
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L976-L1033 |
45,460 | pkgw/pwkit | pwkit/environments/casa/tasks.py | flagmanager_cli | def flagmanager_cli(argv, alter_logger=True):
"""Command-line access to ``flagmanager`` functionality.
The ``flagmanager`` task manages tables of flags associated with
measurement sets. Its features are easy to implement that a standalone
library function is essentially unnecessary. See the source code... | python | def flagmanager_cli(argv, alter_logger=True):
"""Command-line access to ``flagmanager`` functionality.
The ``flagmanager`` task manages tables of flags associated with
measurement sets. Its features are easy to implement that a standalone
library function is essentially unnecessary. See the source code... | [
"def",
"flagmanager_cli",
"(",
"argv",
",",
"alter_logger",
"=",
"True",
")",
":",
"check_usage",
"(",
"flagmanager_doc",
",",
"argv",
",",
"usageifnoargs",
"=",
"True",
")",
"if",
"len",
"(",
"argv",
")",
"<",
"3",
":",
"wrong_usage",
"(",
"flagmanager_do... | Command-line access to ``flagmanager`` functionality.
The ``flagmanager`` task manages tables of flags associated with
measurement sets. Its features are easy to implement that a standalone
library function is essentially unnecessary. See the source code to this
function for the tool calls that impleme... | [
"Command",
"-",
"line",
"access",
"to",
"flagmanager",
"functionality",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L1192-L1258 |
45,461 | pkgw/pwkit | pwkit/environments/casa/tasks.py | image2fits | def image2fits(mspath, fitspath, velocity=False, optical=False, bitpix=-32,
minpix=0, maxpix=-1, overwrite=False, dropstokes=False, stokeslast=True,
history=True, **kwargs):
"""Convert an image in MS format to FITS format.
mspath (str)
The path to the input MS.
fitspat... | python | def image2fits(mspath, fitspath, velocity=False, optical=False, bitpix=-32,
minpix=0, maxpix=-1, overwrite=False, dropstokes=False, stokeslast=True,
history=True, **kwargs):
"""Convert an image in MS format to FITS format.
mspath (str)
The path to the input MS.
fitspat... | [
"def",
"image2fits",
"(",
"mspath",
",",
"fitspath",
",",
"velocity",
"=",
"False",
",",
"optical",
"=",
"False",
",",
"bitpix",
"=",
"-",
"32",
",",
"minpix",
"=",
"0",
",",
"maxpix",
"=",
"-",
"1",
",",
"overwrite",
"=",
"False",
",",
"dropstokes",... | Convert an image in MS format to FITS format.
mspath (str)
The path to the input MS.
fitspath (str)
The path to the output FITS file.
velocity (boolean)
(To be documented.)
optical (boolean)
(To be documented.)
bitpix (integer)
(To be documented.)
minpix (integer)
... | [
"Convert",
"an",
"image",
"in",
"MS",
"format",
"to",
"FITS",
"format",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L2203-L2240 |
45,462 | pkgw/pwkit | pwkit/environments/casa/tasks.py | importalma | def importalma(asdm, ms):
"""Convert an ALMA low-level ASDM dataset to Measurement Set format.
asdm (str)
The path to the input ASDM dataset.
ms (str)
The path to the output MS dataset.
This implementation automatically infers the value of the "tbuff"
parameter.
Example::
f... | python | def importalma(asdm, ms):
"""Convert an ALMA low-level ASDM dataset to Measurement Set format.
asdm (str)
The path to the input ASDM dataset.
ms (str)
The path to the output MS dataset.
This implementation automatically infers the value of the "tbuff"
parameter.
Example::
f... | [
"def",
"importalma",
"(",
"asdm",
",",
"ms",
")",
":",
"from",
".",
"scripting",
"import",
"CasapyScript",
"script",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'cscript_importalma.py'",
")",
... | Convert an ALMA low-level ASDM dataset to Measurement Set format.
asdm (str)
The path to the input ASDM dataset.
ms (str)
The path to the output MS dataset.
This implementation automatically infers the value of the "tbuff"
parameter.
Example::
from pwkit.environments.casa impor... | [
"Convert",
"an",
"ALMA",
"low",
"-",
"level",
"ASDM",
"dataset",
"to",
"Measurement",
"Set",
"format",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L2267-L2288 |
45,463 | pkgw/pwkit | pwkit/environments/casa/tasks.py | importevla | def importevla(asdm, ms):
"""Convert an EVLA low-level SDM dataset to Measurement Set format.
asdm (str)
The path to the input ASDM dataset.
ms (str)
The path to the output MS dataset.
This implementation automatically infers the value of the "tbuff"
parameter.
Example::
fr... | python | def importevla(asdm, ms):
"""Convert an EVLA low-level SDM dataset to Measurement Set format.
asdm (str)
The path to the input ASDM dataset.
ms (str)
The path to the output MS dataset.
This implementation automatically infers the value of the "tbuff"
parameter.
Example::
fr... | [
"def",
"importevla",
"(",
"asdm",
",",
"ms",
")",
":",
"from",
".",
"scripting",
"import",
"CasapyScript",
"# Here's the best way I can figure to find the recommended value of tbuff",
"#(= 1.5 * integration time). Obviously you might have different",
"# integration times in the dataset... | Convert an EVLA low-level SDM dataset to Measurement Set format.
asdm (str)
The path to the input ASDM dataset.
ms (str)
The path to the output MS dataset.
This implementation automatically infers the value of the "tbuff"
parameter.
Example::
from pwkit.environments.casa import... | [
"Convert",
"an",
"EVLA",
"low",
"-",
"level",
"SDM",
"dataset",
"to",
"Measurement",
"Set",
"format",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L2314-L2368 |
45,464 | pkgw/pwkit | pwkit/environments/casa/tasks.py | listobs | def listobs(vis):
"""Textually describe the contents of a measurement set.
vis (str)
The path to the dataset.
Returns
A generator of lines of human-readable output
Errors can only be detected by looking at the output. Example::
from pwkit.environments.casa import tasks
for li... | python | def listobs(vis):
"""Textually describe the contents of a measurement set.
vis (str)
The path to the dataset.
Returns
A generator of lines of human-readable output
Errors can only be detected by looking at the output. Example::
from pwkit.environments.casa import tasks
for li... | [
"def",
"listobs",
"(",
"vis",
")",
":",
"def",
"inner_list",
"(",
"sink",
")",
":",
"try",
":",
"ms",
"=",
"util",
".",
"tools",
".",
"ms",
"(",
")",
"ms",
".",
"open",
"(",
"vis",
")",
"ms",
".",
"summary",
"(",
"verbose",
"=",
"True",
")",
... | Textually describe the contents of a measurement set.
vis (str)
The path to the dataset.
Returns
A generator of lines of human-readable output
Errors can only be detected by looking at the output. Example::
from pwkit.environments.casa import tasks
for line in tasks.listobs('myda... | [
"Textually",
"describe",
"the",
"contents",
"of",
"a",
"measurement",
"set",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L2392-L2422 |
45,465 | pkgw/pwkit | pwkit/environments/casa/tasks.py | mjd2date | def mjd2date(mjd, precision=3):
"""Convert an MJD to a data string in the format used by CASA.
mjd (numeric)
An MJD value in the UTC timescale.
precision (integer, default 3)
The number of digits of decimal precision in the seconds portion of
the returned string
Returns
A string... | python | def mjd2date(mjd, precision=3):
"""Convert an MJD to a data string in the format used by CASA.
mjd (numeric)
An MJD value in the UTC timescale.
precision (integer, default 3)
The number of digits of decimal precision in the seconds portion of
the returned string
Returns
A string... | [
"def",
"mjd2date",
"(",
"mjd",
",",
"precision",
"=",
"3",
")",
":",
"from",
"astropy",
".",
"time",
"import",
"Time",
"dt",
"=",
"Time",
"(",
"mjd",
",",
"format",
"=",
"'mjd'",
",",
"scale",
"=",
"'utc'",
")",
".",
"to_datetime",
"(",
")",
"fracs... | Convert an MJD to a data string in the format used by CASA.
mjd (numeric)
An MJD value in the UTC timescale.
precision (integer, default 3)
The number of digits of decimal precision in the seconds portion of
the returned string
Returns
A string representing the input argument in CAS... | [
"Convert",
"an",
"MJD",
"to",
"a",
"data",
"string",
"in",
"the",
"format",
"used",
"by",
"CASA",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L3208-L3232 |
45,466 | pkgw/pwkit | pwkit/environments/casa/tasks.py | plotants | def plotants(vis, figfile):
"""Plot the physical layout of the antennas described in the MS.
vis (str)
Path to the input dataset
figfile (str)
Path to the output image file.
The output image format will be inferred from the extension of *figfile*.
Example::
from pwkit.environmen... | python | def plotants(vis, figfile):
"""Plot the physical layout of the antennas described in the MS.
vis (str)
Path to the input dataset
figfile (str)
Path to the output image file.
The output image format will be inferred from the extension of *figfile*.
Example::
from pwkit.environmen... | [
"def",
"plotants",
"(",
"vis",
",",
"figfile",
")",
":",
"from",
".",
"scripting",
"import",
"CasapyScript",
"script",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'cscript_plotants.py'",
")",
... | Plot the physical layout of the antennas described in the MS.
vis (str)
Path to the input dataset
figfile (str)
Path to the output image file.
The output image format will be inferred from the extension of *figfile*.
Example::
from pwkit.environments.casa import tasks
tasks.pl... | [
"Plot",
"the",
"physical",
"layout",
"of",
"the",
"antennas",
"described",
"in",
"the",
"MS",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/tasks.py#L3378-L3398 |
45,467 | pkgw/pwkit | pwkit/latex.py | latexify | def latexify(obj, **kwargs):
"""Render an object in LaTeX appropriately.
"""
if hasattr(obj, '__pk_latex__'):
return obj.__pk_latex__(**kwargs)
if isinstance(obj, text_type):
from .unicode_to_latex import unicode_to_latex
return unicode_to_latex(obj)
if isinstance(obj, boo... | python | def latexify(obj, **kwargs):
"""Render an object in LaTeX appropriately.
"""
if hasattr(obj, '__pk_latex__'):
return obj.__pk_latex__(**kwargs)
if isinstance(obj, text_type):
from .unicode_to_latex import unicode_to_latex
return unicode_to_latex(obj)
if isinstance(obj, boo... | [
"def",
"latexify",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'__pk_latex__'",
")",
":",
"return",
"obj",
".",
"__pk_latex__",
"(",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(",
"obj",
",",
"text_type",
")",... | Render an object in LaTeX appropriately. | [
"Render",
"an",
"object",
"in",
"LaTeX",
"appropriately",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L145-L174 |
45,468 | pkgw/pwkit | pwkit/latex.py | latexify_n2col | def latexify_n2col(x, nplaces=None, **kwargs):
"""Render a number into LaTeX in a 2-column format, where the columns split
immediately to the left of the decimal point. This gives nice alignment of
numbers in a table.
"""
if nplaces is not None:
t = '%.*f' % (nplaces, x)
else:
t... | python | def latexify_n2col(x, nplaces=None, **kwargs):
"""Render a number into LaTeX in a 2-column format, where the columns split
immediately to the left of the decimal point. This gives nice alignment of
numbers in a table.
"""
if nplaces is not None:
t = '%.*f' % (nplaces, x)
else:
t... | [
"def",
"latexify_n2col",
"(",
"x",
",",
"nplaces",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"nplaces",
"is",
"not",
"None",
":",
"t",
"=",
"'%.*f'",
"%",
"(",
"nplaces",
",",
"x",
")",
"else",
":",
"t",
"=",
"'%f'",
"%",
"x",
"if",... | Render a number into LaTeX in a 2-column format, where the columns split
immediately to the left of the decimal point. This gives nice alignment of
numbers in a table. | [
"Render",
"a",
"number",
"into",
"LaTeX",
"in",
"a",
"2",
"-",
"column",
"format",
"where",
"the",
"columns",
"split",
"immediately",
"to",
"the",
"left",
"of",
"the",
"decimal",
"point",
".",
"This",
"gives",
"nice",
"alignment",
"of",
"numbers",
"in",
... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L177-L192 |
45,469 | pkgw/pwkit | pwkit/latex.py | latexify_u3col | def latexify_u3col(obj, **kwargs):
"""Convert an object to special LaTeX for uncertainty tables.
This conversion is meant for uncertain values in a table. The return value
should span three columns. The first column ends just before the decimal
point in the main number value, if it has one. It has no s... | python | def latexify_u3col(obj, **kwargs):
"""Convert an object to special LaTeX for uncertainty tables.
This conversion is meant for uncertain values in a table. The return value
should span three columns. The first column ends just before the decimal
point in the main number value, if it has one. It has no s... | [
"def",
"latexify_u3col",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'__pk_latex_u3col__'",
")",
":",
"return",
"obj",
".",
"__pk_latex_u3col__",
"(",
"*",
"*",
"kwargs",
")",
"# TODO: there are reasonable ways to format man... | Convert an object to special LaTeX for uncertainty tables.
This conversion is meant for uncertain values in a table. The return value
should span three columns. The first column ends just before the decimal
point in the main number value, if it has one. It has no separation from
the second column. The ... | [
"Convert",
"an",
"object",
"to",
"special",
"LaTeX",
"for",
"uncertainty",
"tables",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L195-L213 |
45,470 | pkgw/pwkit | pwkit/latex.py | latexify_l3col | def latexify_l3col(obj, **kwargs):
"""Convert an object to special LaTeX for limit tables.
This conversion is meant for limit values in a table. The return value
should span three columns. The first column is the limit indicator: <, >,
~, etc. The second column is the whole part of the value, up until ... | python | def latexify_l3col(obj, **kwargs):
"""Convert an object to special LaTeX for limit tables.
This conversion is meant for limit values in a table. The return value
should span three columns. The first column is the limit indicator: <, >,
~, etc. The second column is the whole part of the value, up until ... | [
"def",
"latexify_l3col",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'__pk_latex_l3col__'",
")",
":",
"return",
"obj",
".",
"__pk_latex_l3col__",
"(",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(",
"obj",
",",
"... | Convert an object to special LaTeX for limit tables.
This conversion is meant for limit values in a table. The return value
should span three columns. The first column is the limit indicator: <, >,
~, etc. The second column is the whole part of the value, up until just
before the decimal point. The thi... | [
"Convert",
"an",
"object",
"to",
"special",
"LaTeX",
"for",
"limit",
"tables",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/latex.py#L216-L241 |
45,471 | pkgw/pwkit | pwkit/tabfile.py | read | def read (path, tabwidth=8, **kwargs):
"""Read a typed tabular text file into a stream of Holders.
Arguments:
path
The path of the file to read.
tabwidth=8
The tab width to assume. Please don't monkey with it.
mode='rt'
The file open mode (passed to io.open()).
noexistok=Fals... | python | def read (path, tabwidth=8, **kwargs):
"""Read a typed tabular text file into a stream of Holders.
Arguments:
path
The path of the file to read.
tabwidth=8
The tab width to assume. Please don't monkey with it.
mode='rt'
The file open mode (passed to io.open()).
noexistok=Fals... | [
"def",
"read",
"(",
"path",
",",
"tabwidth",
"=",
"8",
",",
"*",
"*",
"kwargs",
")",
":",
"datamode",
"=",
"False",
"fixedcols",
"=",
"{",
"}",
"for",
"text",
"in",
"_trimmedlines",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"text",
"=",
"te... | Read a typed tabular text file into a stream of Holders.
Arguments:
path
The path of the file to read.
tabwidth=8
The tab width to assume. Please don't monkey with it.
mode='rt'
The file open mode (passed to io.open()).
noexistok=False
If True and the file is missing, treat... | [
"Read",
"a",
"typed",
"tabular",
"text",
"file",
"into",
"a",
"stream",
"of",
"Holders",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/tabfile.py#L45-L123 |
45,472 | pkgw/pwkit | pwkit/tabfile.py | write | def write (stream, items, fieldnames, tabwidth=8):
"""Write a typed tabular text file to the specified stream.
Arguments:
stream
The destination stream.
items
An iterable of items to write. Two passes have to
be made over the items (to discover the needed column widths),
so thi... | python | def write (stream, items, fieldnames, tabwidth=8):
"""Write a typed tabular text file to the specified stream.
Arguments:
stream
The destination stream.
items
An iterable of items to write. Two passes have to
be made over the items (to discover the needed column widths),
so thi... | [
"def",
"write",
"(",
"stream",
",",
"items",
",",
"fieldnames",
",",
"tabwidth",
"=",
"8",
")",
":",
"if",
"isinstance",
"(",
"fieldnames",
",",
"six",
".",
"string_types",
")",
":",
"fieldnames",
"=",
"fieldnames",
".",
"split",
"(",
")",
"maxlens",
"... | Write a typed tabular text file to the specified stream.
Arguments:
stream
The destination stream.
items
An iterable of items to write. Two passes have to
be made over the items (to discover the needed column widths),
so this will be saved into a list.
fieldnames
Either a... | [
"Write",
"a",
"typed",
"tabular",
"text",
"file",
"to",
"the",
"specified",
"stream",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/tabfile.py#L140-L227 |
45,473 | pkgw/pwkit | pwkit/tabfile.py | vizread | def vizread (descpath, descsection, tabpath, tabwidth=8, **kwargs):
"""Read a headerless tabular text file into a stream of Holders.
Arguments:
descpath
The path of the table description ini file.
descsection
The section in the description file to use.
tabpath
The path to the act... | python | def vizread (descpath, descsection, tabpath, tabwidth=8, **kwargs):
"""Read a headerless tabular text file into a stream of Holders.
Arguments:
descpath
The path of the table description ini file.
descsection
The section in the description file to use.
tabpath
The path to the act... | [
"def",
"vizread",
"(",
"descpath",
",",
"descsection",
",",
"tabpath",
",",
"tabwidth",
"=",
"8",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"inifile",
"import",
"read",
"as",
"iniread",
"cols",
"=",
"[",
"]",
"for",
"i",
"in",
"iniread",
"(",
... | Read a headerless tabular text file into a stream of Holders.
Arguments:
descpath
The path of the table description ini file.
descsection
The section in the description file to use.
tabpath
The path to the actual table data.
tabwidth=8
The tab width to assume. Please don't ... | [
"Read",
"a",
"headerless",
"tabular",
"text",
"file",
"into",
"a",
"stream",
"of",
"Holders",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/tabfile.py#L230-L297 |
45,474 | pkgw/pwkit | pwkit/lsqmdl.py | _broadcast_shapes | def _broadcast_shapes(s1, s2):
"""Given array shapes `s1` and `s2`, compute the shape of the array that would
result from broadcasting them together."""
n1 = len(s1)
n2 = len(s2)
n = max(n1, n2)
res = [1] * n
for i in range(n):
if i >= n1:
c1 = 1
else:
... | python | def _broadcast_shapes(s1, s2):
"""Given array shapes `s1` and `s2`, compute the shape of the array that would
result from broadcasting them together."""
n1 = len(s1)
n2 = len(s2)
n = max(n1, n2)
res = [1] * n
for i in range(n):
if i >= n1:
c1 = 1
else:
... | [
"def",
"_broadcast_shapes",
"(",
"s1",
",",
"s2",
")",
":",
"n1",
"=",
"len",
"(",
"s1",
")",
"n2",
"=",
"len",
"(",
"s2",
")",
"n",
"=",
"max",
"(",
"n1",
",",
"n2",
")",
"res",
"=",
"[",
"1",
"]",
"*",
"n",
"for",
"i",
"in",
"range",
"(... | Given array shapes `s1` and `s2`, compute the shape of the array that would
result from broadcasting them together. | [
"Given",
"array",
"shapes",
"s1",
"and",
"s2",
"compute",
"the",
"shape",
"of",
"the",
"array",
"that",
"would",
"result",
"from",
"broadcasting",
"them",
"together",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L757-L786 |
45,475 | pkgw/pwkit | pwkit/lsqmdl.py | ModelBase.set_data | def set_data(self, data, invsigma=None):
"""Set the data to be modeled.
Returns *self*.
"""
self.data = np.array(data, dtype=np.float, ndmin=1)
if invsigma is None:
self.invsigma = np.ones(self.data.shape)
else:
i = np.array(invsigma, dtype=np.f... | python | def set_data(self, data, invsigma=None):
"""Set the data to be modeled.
Returns *self*.
"""
self.data = np.array(data, dtype=np.float, ndmin=1)
if invsigma is None:
self.invsigma = np.ones(self.data.shape)
else:
i = np.array(invsigma, dtype=np.f... | [
"def",
"set_data",
"(",
"self",
",",
"data",
",",
"invsigma",
"=",
"None",
")",
":",
"self",
".",
"data",
"=",
"np",
".",
"array",
"(",
"data",
",",
"dtype",
"=",
"np",
".",
"float",
",",
"ndmin",
"=",
"1",
")",
"if",
"invsigma",
"is",
"None",
... | Set the data to be modeled.
Returns *self*. | [
"Set",
"the",
"data",
"to",
"be",
"modeled",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L126-L143 |
45,476 | pkgw/pwkit | pwkit/lsqmdl.py | ModelBase.print_soln | def print_soln(self):
"""Print information about the model solution."""
lmax = reduce(max,(len(x) for x in self.pnames), len('r chi sq'))
if self.puncerts is None:
for pn, val in zip(self.pnames, self.params):
print('%s: %14g' % (pn.rjust(lmax), val))
else:
... | python | def print_soln(self):
"""Print information about the model solution."""
lmax = reduce(max,(len(x) for x in self.pnames), len('r chi sq'))
if self.puncerts is None:
for pn, val in zip(self.pnames, self.params):
print('%s: %14g' % (pn.rjust(lmax), val))
else:
... | [
"def",
"print_soln",
"(",
"self",
")",
":",
"lmax",
"=",
"reduce",
"(",
"max",
",",
"(",
"len",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"pnames",
")",
",",
"len",
"(",
"'r chi sq'",
")",
")",
"if",
"self",
".",
"puncerts",
"is",
"None",
"... | Print information about the model solution. | [
"Print",
"information",
"about",
"the",
"model",
"solution",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L146-L164 |
45,477 | pkgw/pwkit | pwkit/lsqmdl.py | ModelBase.show_corr | def show_corr(self):
"Show the parameter correlation matrix with `pwkit.ndshow_gtk3`."
from .ndshow_gtk3 import view
d = np.diag(self.covar) ** -0.5
corr = self.covar * d[np.newaxis,:] * d[:,np.newaxis]
view(corr, title='Correlation Matrix') | python | def show_corr(self):
"Show the parameter correlation matrix with `pwkit.ndshow_gtk3`."
from .ndshow_gtk3 import view
d = np.diag(self.covar) ** -0.5
corr = self.covar * d[np.newaxis,:] * d[:,np.newaxis]
view(corr, title='Correlation Matrix') | [
"def",
"show_corr",
"(",
"self",
")",
":",
"from",
".",
"ndshow_gtk3",
"import",
"view",
"d",
"=",
"np",
".",
"diag",
"(",
"self",
".",
"covar",
")",
"**",
"-",
"0.5",
"corr",
"=",
"self",
".",
"covar",
"*",
"d",
"[",
"np",
".",
"newaxis",
",",
... | Show the parameter correlation matrix with `pwkit.ndshow_gtk3`. | [
"Show",
"the",
"parameter",
"correlation",
"matrix",
"with",
"pwkit",
".",
"ndshow_gtk3",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L246-L251 |
45,478 | pkgw/pwkit | pwkit/lsqmdl.py | Model.set_func | def set_func(self, func, pnames, args=()):
"""Set the model function to use an efficient but tedious calling convention.
The function should obey the following convention::
def func(param_vec, *args):
modeled_data = { do something using param_vec }
return mo... | python | def set_func(self, func, pnames, args=()):
"""Set the model function to use an efficient but tedious calling convention.
The function should obey the following convention::
def func(param_vec, *args):
modeled_data = { do something using param_vec }
return mo... | [
"def",
"set_func",
"(",
"self",
",",
"func",
",",
"pnames",
",",
"args",
"=",
"(",
")",
")",
":",
"from",
".",
"lmmin",
"import",
"Problem",
"self",
".",
"func",
"=",
"func",
"self",
".",
"_args",
"=",
"args",
"self",
".",
"pnames",
"=",
"list",
... | Set the model function to use an efficient but tedious calling convention.
The function should obey the following convention::
def func(param_vec, *args):
modeled_data = { do something using param_vec }
return modeled_data
This function creates the :class:`... | [
"Set",
"the",
"model",
"function",
"to",
"use",
"an",
"efficient",
"but",
"tedious",
"calling",
"convention",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L297-L318 |
45,479 | pkgw/pwkit | pwkit/lsqmdl.py | Model.set_simple_func | def set_simple_func(self, func, args=()):
"""Set the model function to use a simple but somewhat inefficient calling
convention.
The function should obey the following convention::
def func(param0, param1, ..., paramN, *args):
modeled_data = { do something using the... | python | def set_simple_func(self, func, args=()):
"""Set the model function to use a simple but somewhat inefficient calling
convention.
The function should obey the following convention::
def func(param0, param1, ..., paramN, *args):
modeled_data = { do something using the... | [
"def",
"set_simple_func",
"(",
"self",
",",
"func",
",",
"args",
"=",
"(",
")",
")",
":",
"code",
"=",
"get_function_code",
"(",
"func",
")",
"npar",
"=",
"code",
".",
"co_argcount",
"-",
"len",
"(",
"args",
")",
"pnames",
"=",
"code",
".",
"co_varna... | Set the model function to use a simple but somewhat inefficient calling
convention.
The function should obey the following convention::
def func(param0, param1, ..., paramN, *args):
modeled_data = { do something using the parameters }
return modeled_data
... | [
"Set",
"the",
"model",
"function",
"to",
"use",
"a",
"simple",
"but",
"somewhat",
"inefficient",
"calling",
"convention",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L321-L341 |
45,480 | pkgw/pwkit | pwkit/lsqmdl.py | Model.make_frozen_func | def make_frozen_func(self, params):
"""Returns a model function frozen to the specified parameter values.
Any remaining arguments are left free and must be provided when the
function is called.
For this model, the returned function is the application of
:func:`functools.partial... | python | def make_frozen_func(self, params):
"""Returns a model function frozen to the specified parameter values.
Any remaining arguments are left free and must be provided when the
function is called.
For this model, the returned function is the application of
:func:`functools.partial... | [
"def",
"make_frozen_func",
"(",
"self",
",",
"params",
")",
":",
"params",
"=",
"np",
".",
"array",
"(",
"params",
",",
"dtype",
"=",
"np",
".",
"float",
",",
"ndmin",
"=",
"1",
")",
"from",
"functools",
"import",
"partial",
"return",
"partial",
"(",
... | Returns a model function frozen to the specified parameter values.
Any remaining arguments are left free and must be provided when the
function is called.
For this model, the returned function is the application of
:func:`functools.partial` to the :attr:`func` property of this object. | [
"Returns",
"a",
"model",
"function",
"frozen",
"to",
"the",
"specified",
"parameter",
"values",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L344-L356 |
45,481 | pkgw/pwkit | pwkit/lsqmdl.py | Model.solve | def solve(self, guess):
"""Solve for the parameters, using an initial guess.
This uses the Levenberg-Marquardt optimizer described in
:mod:`pwkit.lmmin`.
Returns *self*.
"""
guess = np.array(guess, dtype=np.float, ndmin=1)
f = self.func
args = self._arg... | python | def solve(self, guess):
"""Solve for the parameters, using an initial guess.
This uses the Levenberg-Marquardt optimizer described in
:mod:`pwkit.lmmin`.
Returns *self*.
"""
guess = np.array(guess, dtype=np.float, ndmin=1)
f = self.func
args = self._arg... | [
"def",
"solve",
"(",
"self",
",",
"guess",
")",
":",
"guess",
"=",
"np",
".",
"array",
"(",
"guess",
",",
"dtype",
"=",
"np",
".",
"float",
",",
"ndmin",
"=",
"1",
")",
"f",
"=",
"self",
".",
"func",
"args",
"=",
"self",
".",
"_args",
"def",
... | Solve for the parameters, using an initial guess.
This uses the Levenberg-Marquardt optimizer described in
:mod:`pwkit.lmmin`.
Returns *self*. | [
"Solve",
"for",
"the",
"parameters",
"using",
"an",
"initial",
"guess",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L359-L394 |
45,482 | pkgw/pwkit | pwkit/lsqmdl.py | PolynomialModel.as_nonlinear | def as_nonlinear(self, params=None):
"""Return a `Model` equivalent to this object. The nonlinear solver is less
efficient, but lets you freeze parameters, compute uncertainties, etc.
If the `params` argument is provided, solve() will be called on the
returned object with those paramete... | python | def as_nonlinear(self, params=None):
"""Return a `Model` equivalent to this object. The nonlinear solver is less
efficient, but lets you freeze parameters, compute uncertainties, etc.
If the `params` argument is provided, solve() will be called on the
returned object with those paramete... | [
"def",
"as_nonlinear",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"self",
".",
"params",
"nlm",
"=",
"Model",
"(",
"None",
",",
"self",
".",
"data",
",",
"self",
".",
"invsigma",
")",
"nlm",... | Return a `Model` equivalent to this object. The nonlinear solver is less
efficient, but lets you freeze parameters, compute uncertainties, etc.
If the `params` argument is provided, solve() will be called on the
returned object with those parameters. If it is `None` and this object
has ... | [
"Return",
"a",
"Model",
"equivalent",
"to",
"this",
"object",
".",
"The",
"nonlinear",
"solver",
"is",
"less",
"efficient",
"but",
"lets",
"you",
"freeze",
"parameters",
"compute",
"uncertainties",
"etc",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lsqmdl.py#L444-L464 |
45,483 | bibanon/BASC-py4chan | basc_py4chan/thread.py | Thread.files | def files(self):
"""Returns the URLs of all files attached to posts in the thread."""
if self.topic.has_file:
yield self.topic.file.file_url
for reply in self.replies:
if reply.has_file:
yield reply.file.file_url | python | def files(self):
"""Returns the URLs of all files attached to posts in the thread."""
if self.topic.has_file:
yield self.topic.file.file_url
for reply in self.replies:
if reply.has_file:
yield reply.file.file_url | [
"def",
"files",
"(",
"self",
")",
":",
"if",
"self",
".",
"topic",
".",
"has_file",
":",
"yield",
"self",
".",
"topic",
".",
"file",
".",
"file_url",
"for",
"reply",
"in",
"self",
".",
"replies",
":",
"if",
"reply",
".",
"has_file",
":",
"yield",
"... | Returns the URLs of all files attached to posts in the thread. | [
"Returns",
"the",
"URLs",
"of",
"all",
"files",
"attached",
"to",
"posts",
"in",
"the",
"thread",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L105-L111 |
45,484 | bibanon/BASC-py4chan | basc_py4chan/thread.py | Thread.thumbs | def thumbs(self):
"""Returns the URLs of all thumbnails in the thread."""
if self.topic.has_file:
yield self.topic.file.thumbnail_url
for reply in self.replies:
if reply.has_file:
yield reply.file.thumbnail_url | python | def thumbs(self):
"""Returns the URLs of all thumbnails in the thread."""
if self.topic.has_file:
yield self.topic.file.thumbnail_url
for reply in self.replies:
if reply.has_file:
yield reply.file.thumbnail_url | [
"def",
"thumbs",
"(",
"self",
")",
":",
"if",
"self",
".",
"topic",
".",
"has_file",
":",
"yield",
"self",
".",
"topic",
".",
"file",
".",
"thumbnail_url",
"for",
"reply",
"in",
"self",
".",
"replies",
":",
"if",
"reply",
".",
"has_file",
":",
"yield... | Returns the URLs of all thumbnails in the thread. | [
"Returns",
"the",
"URLs",
"of",
"all",
"thumbnails",
"in",
"the",
"thread",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L113-L119 |
45,485 | bibanon/BASC-py4chan | basc_py4chan/thread.py | Thread.filenames | def filenames(self):
"""Returns the filenames of all files attached to posts in the thread."""
if self.topic.has_file:
yield self.topic.file.filename
for reply in self.replies:
if reply.has_file:
yield reply.file.filename | python | def filenames(self):
"""Returns the filenames of all files attached to posts in the thread."""
if self.topic.has_file:
yield self.topic.file.filename
for reply in self.replies:
if reply.has_file:
yield reply.file.filename | [
"def",
"filenames",
"(",
"self",
")",
":",
"if",
"self",
".",
"topic",
".",
"has_file",
":",
"yield",
"self",
".",
"topic",
".",
"file",
".",
"filename",
"for",
"reply",
"in",
"self",
".",
"replies",
":",
"if",
"reply",
".",
"has_file",
":",
"yield",... | Returns the filenames of all files attached to posts in the thread. | [
"Returns",
"the",
"filenames",
"of",
"all",
"files",
"attached",
"to",
"posts",
"in",
"the",
"thread",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L121-L127 |
45,486 | bibanon/BASC-py4chan | basc_py4chan/thread.py | Thread.thumbnames | def thumbnames(self):
"""Returns the filenames of all thumbnails in the thread."""
if self.topic.has_file:
yield self.topic.file.thumbnail_fname
for reply in self.replies:
if reply.has_file:
yield reply.file.thumbnail_fname | python | def thumbnames(self):
"""Returns the filenames of all thumbnails in the thread."""
if self.topic.has_file:
yield self.topic.file.thumbnail_fname
for reply in self.replies:
if reply.has_file:
yield reply.file.thumbnail_fname | [
"def",
"thumbnames",
"(",
"self",
")",
":",
"if",
"self",
".",
"topic",
".",
"has_file",
":",
"yield",
"self",
".",
"topic",
".",
"file",
".",
"thumbnail_fname",
"for",
"reply",
"in",
"self",
".",
"replies",
":",
"if",
"reply",
".",
"has_file",
":",
... | Returns the filenames of all thumbnails in the thread. | [
"Returns",
"the",
"filenames",
"of",
"all",
"thumbnails",
"in",
"the",
"thread",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L129-L135 |
45,487 | bibanon/BASC-py4chan | basc_py4chan/thread.py | Thread.update | def update(self, force=False):
"""Fetch new posts from the server.
Arguments:
force (bool): Force a thread update, even if thread has 404'd.
Returns:
int: How many new posts have been fetched.
"""
# The thread has already 404'ed, this function shouldn't... | python | def update(self, force=False):
"""Fetch new posts from the server.
Arguments:
force (bool): Force a thread update, even if thread has 404'd.
Returns:
int: How many new posts have been fetched.
"""
# The thread has already 404'ed, this function shouldn't... | [
"def",
"update",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"# The thread has already 404'ed, this function shouldn't do anything anymore.",
"if",
"self",
".",
"is_404",
"and",
"not",
"force",
":",
"return",
"0",
"if",
"self",
".",
"_last_modified",
":",
"... | Fetch new posts from the server.
Arguments:
force (bool): Force a thread update, even if thread has 404'd.
Returns:
int: How many new posts have been fetched. | [
"Fetch",
"new",
"posts",
"from",
"the",
"server",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/thread.py#L145-L214 |
45,488 | pkgw/pwkit | pwkit/radio_cal_models.py | cas_a | def cas_a (freq_mhz, year):
"""Return the flux of Cas A given a frequency and the year of observation.
Based on the formula given in Baars et al., 1977.
Parameters:
freq - Observation frequency in MHz.
year - Year of observation. May be floating-point.
Returns: s, flux in Jy.
"""
# T... | python | def cas_a (freq_mhz, year):
"""Return the flux of Cas A given a frequency and the year of observation.
Based on the formula given in Baars et al., 1977.
Parameters:
freq - Observation frequency in MHz.
year - Year of observation. May be floating-point.
Returns: s, flux in Jy.
"""
# T... | [
"def",
"cas_a",
"(",
"freq_mhz",
",",
"year",
")",
":",
"# The snu rule is right out of Baars et al. The dnu is corrected",
"# for the frequency being measured in MHz, not GHz.",
"snu",
"=",
"10.",
"**",
"(",
"5.745",
"-",
"0.770",
"*",
"np",
".",
"log10",
"(",
"freq_mh... | Return the flux of Cas A given a frequency and the year of observation.
Based on the formula given in Baars et al., 1977.
Parameters:
freq - Observation frequency in MHz.
year - Year of observation. May be floating-point.
Returns: s, flux in Jy. | [
"Return",
"the",
"flux",
"of",
"Cas",
"A",
"given",
"a",
"frequency",
"and",
"the",
"year",
"of",
"observation",
".",
"Based",
"on",
"the",
"formula",
"given",
"in",
"Baars",
"et",
"al",
".",
"1977",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/radio_cal_models.py#L44-L62 |
45,489 | pkgw/pwkit | pwkit/radio_cal_models.py | init_cas_a | def init_cas_a (year):
"""Insert an entry for Cas A into the table of models. Need to specify the
year of the observations to account for the time variation of Cas A's
emission.
"""
year = float (year)
models['CasA'] = lambda f: cas_a (f, year) | python | def init_cas_a (year):
"""Insert an entry for Cas A into the table of models. Need to specify the
year of the observations to account for the time variation of Cas A's
emission.
"""
year = float (year)
models['CasA'] = lambda f: cas_a (f, year) | [
"def",
"init_cas_a",
"(",
"year",
")",
":",
"year",
"=",
"float",
"(",
"year",
")",
"models",
"[",
"'CasA'",
"]",
"=",
"lambda",
"f",
":",
"cas_a",
"(",
"f",
",",
"year",
")"
] | Insert an entry for Cas A into the table of models. Need to specify the
year of the observations to account for the time variation of Cas A's
emission. | [
"Insert",
"an",
"entry",
"for",
"Cas",
"A",
"into",
"the",
"table",
"of",
"models",
".",
"Need",
"to",
"specify",
"the",
"year",
"of",
"the",
"observations",
"to",
"account",
"for",
"the",
"time",
"variation",
"of",
"Cas",
"A",
"s",
"emission",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/radio_cal_models.py#L65-L72 |
45,490 | pkgw/pwkit | pwkit/radio_cal_models.py | add_from_vla_obs | def add_from_vla_obs (src, Lband, Cband):
"""Add an entry into the models table for a source based on L-band and
C-band flux densities.
"""
if src in models:
raise PKError ('already have a model for ' + src)
fL = np.log10 (1425)
fC = np.log10 (4860)
lL = np.log10 (Lband)
lC = ... | python | def add_from_vla_obs (src, Lband, Cband):
"""Add an entry into the models table for a source based on L-band and
C-band flux densities.
"""
if src in models:
raise PKError ('already have a model for ' + src)
fL = np.log10 (1425)
fC = np.log10 (4860)
lL = np.log10 (Lband)
lC = ... | [
"def",
"add_from_vla_obs",
"(",
"src",
",",
"Lband",
",",
"Cband",
")",
":",
"if",
"src",
"in",
"models",
":",
"raise",
"PKError",
"(",
"'already have a model for '",
"+",
"src",
")",
"fL",
"=",
"np",
".",
"log10",
"(",
"1425",
")",
"fC",
"=",
"np",
... | Add an entry into the models table for a source based on L-band and
C-band flux densities. | [
"Add",
"an",
"entry",
"into",
"the",
"models",
"table",
"for",
"a",
"source",
"based",
"on",
"L",
"-",
"band",
"and",
"C",
"-",
"band",
"flux",
"densities",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/radio_cal_models.py#L164-L188 |
45,491 | pkgw/pwkit | pwkit/ellipses.py | databiv | def databiv (xy, coordouter=False, **kwargs):
"""Compute the main parameters of a bivariate distribution from data. The
parameters are returned in the same format as used in the rest of this
module.
* xy: a 2D data array of shape (2, nsamp) or (nsamp, 2)
* coordouter: if True, the coordinate axis i... | python | def databiv (xy, coordouter=False, **kwargs):
"""Compute the main parameters of a bivariate distribution from data. The
parameters are returned in the same format as used in the rest of this
module.
* xy: a 2D data array of shape (2, nsamp) or (nsamp, 2)
* coordouter: if True, the coordinate axis i... | [
"def",
"databiv",
"(",
"xy",
",",
"coordouter",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"xy",
"=",
"np",
".",
"asarray",
"(",
"xy",
")",
"if",
"xy",
".",
"ndim",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'\"xy\" must be a 2D array'",
")",... | Compute the main parameters of a bivariate distribution from data. The
parameters are returned in the same format as used in the rest of this
module.
* xy: a 2D data array of shape (2, nsamp) or (nsamp, 2)
* coordouter: if True, the coordinate axis is the outer axis; i.e.
the shape is (2, nsamp).... | [
"Compute",
"the",
"main",
"parameters",
"of",
"a",
"bivariate",
"distribution",
"from",
"data",
".",
"The",
"parameters",
"are",
"returned",
"in",
"the",
"same",
"format",
"as",
"used",
"in",
"the",
"rest",
"of",
"this",
"module",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L183-L216 |
45,492 | pkgw/pwkit | pwkit/ellipses.py | bivrandom | def bivrandom (x0, y0, sx, sy, cxy, size=None):
"""Compute random values distributed according to the specified bivariate
distribution.
Inputs:
* x0: the center of the x distribution (i.e. its intended mean)
* y0: the center of the y distribution
* sx: standard deviation (not variance) of x va... | python | def bivrandom (x0, y0, sx, sy, cxy, size=None):
"""Compute random values distributed according to the specified bivariate
distribution.
Inputs:
* x0: the center of the x distribution (i.e. its intended mean)
* y0: the center of the y distribution
* sx: standard deviation (not variance) of x va... | [
"def",
"bivrandom",
"(",
"x0",
",",
"y0",
",",
"sx",
",",
"sy",
",",
"cxy",
",",
"size",
"=",
"None",
")",
":",
"from",
"numpy",
".",
"random",
"import",
"multivariate_normal",
"as",
"mvn",
"p0",
"=",
"np",
".",
"asarray",
"(",
"[",
"x0",
",",
"y... | Compute random values distributed according to the specified bivariate
distribution.
Inputs:
* x0: the center of the x distribution (i.e. its intended mean)
* y0: the center of the y distribution
* sx: standard deviation (not variance) of x var
* sy: standard deviation (not variance) of y var
... | [
"Compute",
"random",
"values",
"distributed",
"according",
"to",
"the",
"specified",
"bivariate",
"distribution",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L219-L243 |
45,493 | pkgw/pwkit | pwkit/ellipses.py | bivconvolve | def bivconvolve (sx_a, sy_a, cxy_a, sx_b, sy_b, cxy_b):
"""Given two independent bivariate distributions, compute a bivariate
distribution corresponding to their convolution.
I'm sure this is worked out in a ton of places, but I got the equations
from Pineau+ (2011A&A...527A.126P).
Returns: (sx_c,... | python | def bivconvolve (sx_a, sy_a, cxy_a, sx_b, sy_b, cxy_b):
"""Given two independent bivariate distributions, compute a bivariate
distribution corresponding to their convolution.
I'm sure this is worked out in a ton of places, but I got the equations
from Pineau+ (2011A&A...527A.126P).
Returns: (sx_c,... | [
"def",
"bivconvolve",
"(",
"sx_a",
",",
"sy_a",
",",
"cxy_a",
",",
"sx_b",
",",
"sy_b",
",",
"cxy_b",
")",
":",
"_bivcheck",
"(",
"sx_a",
",",
"sy_a",
",",
"cxy_a",
")",
"_bivcheck",
"(",
"sx_b",
",",
"sy_b",
",",
"cxy_b",
")",
"sx_c",
"=",
"np",
... | Given two independent bivariate distributions, compute a bivariate
distribution corresponding to their convolution.
I'm sure this is worked out in a ton of places, but I got the equations
from Pineau+ (2011A&A...527A.126P).
Returns: (sx_c, sy_c, cxy_c), the parameters of the convolved
distribution... | [
"Given",
"two",
"independent",
"bivariate",
"distributions",
"compute",
"a",
"bivariate",
"distribution",
"corresponding",
"to",
"their",
"convolution",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L246-L264 |
45,494 | pkgw/pwkit | pwkit/ellipses.py | ellplot | def ellplot (mjr, mnr, pa):
"""Utility for debugging."""
_ellcheck (mjr, mnr, pa)
import omega as om
th = np.linspace (0, 2 * np.pi, 200)
x, y = ellpoint (mjr, mnr, pa, th)
return om.quickXY (x, y, 'mjr=%f mnr=%f pa=%f' %
(mjr, mnr, pa * 180 / np.pi)) | python | def ellplot (mjr, mnr, pa):
"""Utility for debugging."""
_ellcheck (mjr, mnr, pa)
import omega as om
th = np.linspace (0, 2 * np.pi, 200)
x, y = ellpoint (mjr, mnr, pa, th)
return om.quickXY (x, y, 'mjr=%f mnr=%f pa=%f' %
(mjr, mnr, pa * 180 / np.pi)) | [
"def",
"ellplot",
"(",
"mjr",
",",
"mnr",
",",
"pa",
")",
":",
"_ellcheck",
"(",
"mjr",
",",
"mnr",
",",
"pa",
")",
"import",
"omega",
"as",
"om",
"th",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"2",
"*",
"np",
".",
"pi",
",",
"200",
")",
... | Utility for debugging. | [
"Utility",
"for",
"debugging",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L445-L453 |
45,495 | pkgw/pwkit | pwkit/ellipses.py | abcd2 | def abcd2 (x0, y0, a, b, c, x, y):
"""Given an 2D Gaussian expressed as the ABC polynomial coefficients, compute
a "squared distance parameter" such that
z = exp (-0.5 * d2)
Inputs:
* x0: position of Gaussian center on x axis
* y0: position of Gaussian center on y axis
* a: such that z... | python | def abcd2 (x0, y0, a, b, c, x, y):
"""Given an 2D Gaussian expressed as the ABC polynomial coefficients, compute
a "squared distance parameter" such that
z = exp (-0.5 * d2)
Inputs:
* x0: position of Gaussian center on x axis
* y0: position of Gaussian center on y axis
* a: such that z... | [
"def",
"abcd2",
"(",
"x0",
",",
"y0",
",",
"a",
",",
"b",
",",
"c",
",",
"x",
",",
"y",
")",
":",
"_abccheck",
"(",
"a",
",",
"b",
",",
"c",
")",
"dx",
",",
"dy",
"=",
"x",
"-",
"x0",
",",
"y",
"-",
"y0",
"return",
"-",
"2",
"*",
"(",... | Given an 2D Gaussian expressed as the ABC polynomial coefficients, compute
a "squared distance parameter" such that
z = exp (-0.5 * d2)
Inputs:
* x0: position of Gaussian center on x axis
* y0: position of Gaussian center on y axis
* a: such that z = exp (ax² + bxy + cy²)
* b: see abov... | [
"Given",
"an",
"2D",
"Gaussian",
"expressed",
"as",
"the",
"ABC",
"polynomial",
"coefficients",
"compute",
"a",
"squared",
"distance",
"parameter",
"such",
"that"
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/ellipses.py#L500-L523 |
45,496 | jakevdp/lpproj | lpproj/lpproj.py | eigh_robust | def eigh_robust(a, b=None, eigvals=None, eigvals_only=False,
overwrite_a=False, overwrite_b=False,
turbo=True, check_finite=True):
"""Robustly solve the Hermitian generalized eigenvalue problem
This function robustly solves the Hermetian generalized eigenvalue problem
``A v ... | python | def eigh_robust(a, b=None, eigvals=None, eigvals_only=False,
overwrite_a=False, overwrite_b=False,
turbo=True, check_finite=True):
"""Robustly solve the Hermitian generalized eigenvalue problem
This function robustly solves the Hermetian generalized eigenvalue problem
``A v ... | [
"def",
"eigh_robust",
"(",
"a",
",",
"b",
"=",
"None",
",",
"eigvals",
"=",
"None",
",",
"eigvals_only",
"=",
"False",
",",
"overwrite_a",
"=",
"False",
",",
"overwrite_b",
"=",
"False",
",",
"turbo",
"=",
"True",
",",
"check_finite",
"=",
"True",
")",... | Robustly solve the Hermitian generalized eigenvalue problem
This function robustly solves the Hermetian generalized eigenvalue problem
``A v = lambda B v`` in the case that B is not strictly positive definite.
When B is strictly positive-definite, the result is equivalent to
scipy.linalg.eigh() within ... | [
"Robustly",
"solve",
"the",
"Hermitian",
"generalized",
"eigenvalue",
"problem"
] | 9c9042b0c2d16c153b53dcc0a759c7fe8c272176 | https://github.com/jakevdp/lpproj/blob/9c9042b0c2d16c153b53dcc0a759c7fe8c272176/lpproj/lpproj.py#L105-L173 |
45,497 | jakevdp/lpproj | lpproj/lpproj.py | LocalityPreservingProjection._compute_projection | def _compute_projection(self, X, W):
"""Compute the LPP projection matrix
Parameters
----------
X : array_like, (n_samples, n_features)
The input data
W : array_like or sparse matrix, (n_samples, n_samples)
The precomputed adjacency matrix
Return... | python | def _compute_projection(self, X, W):
"""Compute the LPP projection matrix
Parameters
----------
X : array_like, (n_samples, n_features)
The input data
W : array_like or sparse matrix, (n_samples, n_samples)
The precomputed adjacency matrix
Return... | [
"def",
"_compute_projection",
"(",
"self",
",",
"X",
",",
"W",
")",
":",
"# TODO: check W input; handle sparse case",
"X",
"=",
"check_array",
"(",
"X",
")",
"D",
"=",
"np",
".",
"diag",
"(",
"W",
".",
"sum",
"(",
"1",
")",
")",
"L",
"=",
"D",
"-",
... | Compute the LPP projection matrix
Parameters
----------
X : array_like, (n_samples, n_features)
The input data
W : array_like or sparse matrix, (n_samples, n_samples)
The precomputed adjacency matrix
Returns
-------
P : ndarray, (n_featur... | [
"Compute",
"the",
"LPP",
"projection",
"matrix"
] | 9c9042b0c2d16c153b53dcc0a759c7fe8c272176 | https://github.com/jakevdp/lpproj/blob/9c9042b0c2d16c153b53dcc0a759c7fe8c272176/lpproj/lpproj.py#L57-L80 |
45,498 | andrenarchy/krypy | krypy/utils.py | find_common_dtype | def find_common_dtype(*args):
'''Returns common dtype of numpy and scipy objects.
Recognizes ndarray, spmatrix and LinearOperator. All other objects are
ignored (most notably None).'''
dtypes = []
for arg in args:
if type(arg) is numpy.ndarray or \
isspmatrix(arg) or \
... | python | def find_common_dtype(*args):
'''Returns common dtype of numpy and scipy objects.
Recognizes ndarray, spmatrix and LinearOperator. All other objects are
ignored (most notably None).'''
dtypes = []
for arg in args:
if type(arg) is numpy.ndarray or \
isspmatrix(arg) or \
... | [
"def",
"find_common_dtype",
"(",
"*",
"args",
")",
":",
"dtypes",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"if",
"type",
"(",
"arg",
")",
"is",
"numpy",
".",
"ndarray",
"or",
"isspmatrix",
"(",
"arg",
")",
"or",
"isinstance",
"(",
"arg",
","... | Returns common dtype of numpy and scipy objects.
Recognizes ndarray, spmatrix and LinearOperator. All other objects are
ignored (most notably None). | [
"Returns",
"common",
"dtype",
"of",
"numpy",
"and",
"scipy",
"objects",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L75-L90 |
45,499 | andrenarchy/krypy | krypy/utils.py | inner | def inner(X, Y, ip_B=None):
'''Euclidean and non-Euclidean inner product.
numpy.vdot only works for vectors and numpy.dot does not use the conjugate
transpose.
:param X: numpy array with ``shape==(N,m)``
:param Y: numpy array with ``shape==(N,n)``
:param ip_B: (optional) May be one of the foll... | python | def inner(X, Y, ip_B=None):
'''Euclidean and non-Euclidean inner product.
numpy.vdot only works for vectors and numpy.dot does not use the conjugate
transpose.
:param X: numpy array with ``shape==(N,m)``
:param Y: numpy array with ``shape==(N,n)``
:param ip_B: (optional) May be one of the foll... | [
"def",
"inner",
"(",
"X",
",",
"Y",
",",
"ip_B",
"=",
"None",
")",
":",
"if",
"ip_B",
"is",
"None",
"or",
"isinstance",
"(",
"ip_B",
",",
"IdentityLinearOperator",
")",
":",
"return",
"numpy",
".",
"dot",
"(",
"X",
".",
"T",
".",
"conj",
"(",
")"... | Euclidean and non-Euclidean inner product.
numpy.vdot only works for vectors and numpy.dot does not use the conjugate
transpose.
:param X: numpy array with ``shape==(N,m)``
:param Y: numpy array with ``shape==(N,n)``
:param ip_B: (optional) May be one of the following
* ``None``: Euclidea... | [
"Euclidean",
"and",
"non",
"-",
"Euclidean",
"inner",
"product",
"."
] | 4883ec9a61d64ea56489e15c35cc40f0633ab2f1 | https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L128-L161 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.