partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | calc_crc | Calculate cyclic redundancy check (CRC). | pyvlx/frames/frame_helper.py | def calc_crc(raw):
"""Calculate cyclic redundancy check (CRC)."""
crc = 0
for sym in raw:
crc = crc ^ int(sym)
return crc | def calc_crc(raw):
"""Calculate cyclic redundancy check (CRC)."""
crc = 0
for sym in raw:
crc = crc ^ int(sym)
return crc | [
"Calculate",
"cyclic",
"redundancy",
"check",
"(",
"CRC",
")",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_helper.py#L6-L11 | [
"def",
"calc_crc",
"(",
"raw",
")",
":",
"crc",
"=",
"0",
"for",
"sym",
"in",
"raw",
":",
"crc",
"=",
"crc",
"^",
"int",
"(",
"sym",
")",
"return",
"crc"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | extract_from_frame | Extract payload and command from frame. | pyvlx/frames/frame_helper.py | def extract_from_frame(data):
"""Extract payload and command from frame."""
if len(data) <= 4:
raise PyVLXException("could_not_extract_from_frame_too_short", data=data)
length = data[0] * 256 + data[1] - 1
if len(data) != length + 3:
raise PyVLXException("could_not_extract_from_frame_inv... | def extract_from_frame(data):
"""Extract payload and command from frame."""
if len(data) <= 4:
raise PyVLXException("could_not_extract_from_frame_too_short", data=data)
length = data[0] * 256 + data[1] - 1
if len(data) != length + 3:
raise PyVLXException("could_not_extract_from_frame_inv... | [
"Extract",
"payload",
"and",
"command",
"from",
"frame",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_helper.py#L14-L28 | [
"def",
"extract_from_frame",
"(",
"data",
")",
":",
"if",
"len",
"(",
"data",
")",
"<=",
"4",
":",
"raise",
"PyVLXException",
"(",
"\"could_not_extract_from_frame_too_short\"",
",",
"data",
"=",
"data",
")",
"length",
"=",
"data",
"[",
"0",
"]",
"*",
"256"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameNodeInformationChangedNotification.get_payload | Return Payload. | pyvlx/frames/frame_node_information_changed.py | def get_payload(self):
"""Return Payload."""
payload = bytes([self.node_id])
payload += string_to_bytes(self.name, 64)
payload += bytes([self.order >> 8 & 255, self.order & 255])
payload += bytes([self.placement])
payload += bytes([self.node_variation.value])
retu... | def get_payload(self):
"""Return Payload."""
payload = bytes([self.node_id])
payload += string_to_bytes(self.name, 64)
payload += bytes([self.order >> 8 & 255, self.order & 255])
payload += bytes([self.placement])
payload += bytes([self.node_variation.value])
retu... | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_information_changed.py#L22-L29 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"payload",
"=",
"bytes",
"(",
"[",
"self",
".",
"node_id",
"]",
")",
"payload",
"+=",
"string_to_bytes",
"(",
"self",
".",
"name",
",",
"64",
")",
"payload",
"+=",
"bytes",
"(",
"[",
"self",
".",
"order",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameNodeInformationChangedNotification.from_payload | Init frame from binary data. | pyvlx/frames/frame_node_information_changed.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.name = bytes_to_string(payload[1:65])
self.order = payload[65] * 256 + payload[66]
self.placement = payload[67]
self.node_variation = NodeVariation(payload[68]) | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.name = bytes_to_string(payload[1:65])
self.order = payload[65] * 256 + payload[66]
self.placement = payload[67]
self.node_variation = NodeVariation(payload[68]) | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_information_changed.py#L31-L37 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"node_id",
"=",
"payload",
"[",
"0",
"]",
"self",
".",
"name",
"=",
"bytes_to_string",
"(",
"payload",
"[",
"1",
":",
"65",
"]",
")",
"self",
".",
"order",
"=",
"payload",
"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameGetNodeInformationConfirmation.from_payload | Init frame from binary data. | pyvlx/frames/frame_get_node_information.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = NodeInformationStatus(payload[0])
self.node_id = payload[1] | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = NodeInformationStatus(payload[0])
self.node_id = payload[1] | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_node_information.py#L60-L63 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"status",
"=",
"NodeInformationStatus",
"(",
"payload",
"[",
"0",
"]",
")",
"self",
".",
"node_id",
"=",
"payload",
"[",
"1",
"]"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | BaseSpectrum._get_meta | Extract metadata, if any, from given object. | synphot/spectrum.py | def _get_meta(obj):
"""Extract metadata, if any, from given object."""
if hasattr(obj, 'meta'): # Spectrum or model
meta = deepcopy(obj.meta)
elif isinstance(obj, dict): # Metadata
meta = deepcopy(obj)
else: # Number
meta = {}
return meta | def _get_meta(obj):
"""Extract metadata, if any, from given object."""
if hasattr(obj, 'meta'): # Spectrum or model
meta = deepcopy(obj.meta)
elif isinstance(obj, dict): # Metadata
meta = deepcopy(obj)
else: # Number
meta = {}
return meta | [
"Extract",
"metadata",
"if",
"any",
"from",
"given",
"object",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L193-L201 | [
"def",
"_get_meta",
"(",
"obj",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'meta'",
")",
":",
"# Spectrum or model",
"meta",
"=",
"deepcopy",
"(",
"obj",
".",
"meta",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"# Metadata",
"meta",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum._merge_meta | Merge metadata from left and right onto results.
This is used during class initialization.
This should also be used by operators to merge metadata after
creating a new instance but before returning it.
Result's metadata is modified in-place.
Parameters
----------
... | synphot/spectrum.py | def _merge_meta(left, right, result, clean=True):
"""Merge metadata from left and right onto results.
This is used during class initialization.
This should also be used by operators to merge metadata after
creating a new instance but before returning it.
Result's metadata is mod... | def _merge_meta(left, right, result, clean=True):
"""Merge metadata from left and right onto results.
This is used during class initialization.
This should also be used by operators to merge metadata after
creating a new instance but before returning it.
Result's metadata is mod... | [
"Merge",
"metadata",
"from",
"left",
"and",
"right",
"onto",
"results",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L204-L239 | [
"def",
"_merge_meta",
"(",
"left",
",",
"right",
",",
"result",
",",
"clean",
"=",
"True",
")",
":",
"# Copies are returned because they need some clean-up below.",
"left",
"=",
"BaseSpectrum",
".",
"_get_meta",
"(",
"left",
")",
"right",
"=",
"BaseSpectrum",
".",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum._process_generic_param | Process generic model parameter. | synphot/spectrum.py | def _process_generic_param(pval, def_unit, equivalencies=[]):
"""Process generic model parameter."""
if isinstance(pval, u.Quantity):
outval = pval.to(def_unit, equivalencies).value
else: # Assume already in desired unit
outval = pval
return outval | def _process_generic_param(pval, def_unit, equivalencies=[]):
"""Process generic model parameter."""
if isinstance(pval, u.Quantity):
outval = pval.to(def_unit, equivalencies).value
else: # Assume already in desired unit
outval = pval
return outval | [
"Process",
"generic",
"model",
"parameter",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L242-L248 | [
"def",
"_process_generic_param",
"(",
"pval",
",",
"def_unit",
",",
"equivalencies",
"=",
"[",
"]",
")",
":",
"if",
"isinstance",
"(",
"pval",
",",
"u",
".",
"Quantity",
")",
":",
"outval",
"=",
"pval",
".",
"to",
"(",
"def_unit",
",",
"equivalencies",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum._process_wave_param | Process individual model parameter representing wavelength. | synphot/spectrum.py | def _process_wave_param(self, pval):
"""Process individual model parameter representing wavelength."""
return self._process_generic_param(
pval, self._internal_wave_unit, equivalencies=u.spectral()) | def _process_wave_param(self, pval):
"""Process individual model parameter representing wavelength."""
return self._process_generic_param(
pval, self._internal_wave_unit, equivalencies=u.spectral()) | [
"Process",
"individual",
"model",
"parameter",
"representing",
"wavelength",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L250-L253 | [
"def",
"_process_wave_param",
"(",
"self",
",",
"pval",
")",
":",
"return",
"self",
".",
"_process_generic_param",
"(",
"pval",
",",
"self",
".",
"_internal_wave_unit",
",",
"equivalencies",
"=",
"u",
".",
"spectral",
"(",
")",
")"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.waveset | Optimal wavelengths for sampling the spectrum or bandpass. | synphot/spectrum.py | def waveset(self):
"""Optimal wavelengths for sampling the spectrum or bandpass."""
w = get_waveset(self.model)
if w is not None:
utils.validate_wavelengths(w)
w = w * self._internal_wave_unit
return w | def waveset(self):
"""Optimal wavelengths for sampling the spectrum or bandpass."""
w = get_waveset(self.model)
if w is not None:
utils.validate_wavelengths(w)
w = w * self._internal_wave_unit
return w | [
"Optimal",
"wavelengths",
"for",
"sampling",
"the",
"spectrum",
"or",
"bandpass",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L309-L315 | [
"def",
"waveset",
"(",
"self",
")",
":",
"w",
"=",
"get_waveset",
"(",
"self",
".",
"model",
")",
"if",
"w",
"is",
"not",
"None",
":",
"utils",
".",
"validate_wavelengths",
"(",
"w",
")",
"w",
"=",
"w",
"*",
"self",
".",
"_internal_wave_unit",
"retur... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.waverange | Range of `waveset`. | synphot/spectrum.py | def waverange(self):
"""Range of `waveset`."""
if self.waveset is None:
x = [None, None]
else:
x = u.Quantity([self.waveset.min(), self.waveset.max()])
return x | def waverange(self):
"""Range of `waveset`."""
if self.waveset is None:
x = [None, None]
else:
x = u.Quantity([self.waveset.min(), self.waveset.max()])
return x | [
"Range",
"of",
"waveset",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L318-L324 | [
"def",
"waverange",
"(",
"self",
")",
":",
"if",
"self",
".",
"waveset",
"is",
"None",
":",
"x",
"=",
"[",
"None",
",",
"None",
"]",
"else",
":",
"x",
"=",
"u",
".",
"Quantity",
"(",
"[",
"self",
".",
"waveset",
".",
"min",
"(",
")",
",",
"se... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum._validate_wavelengths | Validate wavelengths for sampling. | synphot/spectrum.py | def _validate_wavelengths(self, wave):
"""Validate wavelengths for sampling."""
if wave is None:
if self.waveset is None:
raise exceptions.SynphotError(
'self.waveset is undefined; '
'Provide wavelengths for sampling.')
wave... | def _validate_wavelengths(self, wave):
"""Validate wavelengths for sampling."""
if wave is None:
if self.waveset is None:
raise exceptions.SynphotError(
'self.waveset is undefined; '
'Provide wavelengths for sampling.')
wave... | [
"Validate",
"wavelengths",
"for",
"sampling",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L330-L343 | [
"def",
"_validate_wavelengths",
"(",
"self",
",",
"wave",
")",
":",
"if",
"wave",
"is",
"None",
":",
"if",
"self",
".",
"waveset",
"is",
"None",
":",
"raise",
"exceptions",
".",
"SynphotError",
"(",
"'self.waveset is undefined; '",
"'Provide wavelengths for sampli... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum._validate_other_mul_div | Conditions for other to satisfy before mul/div. | synphot/spectrum.py | def _validate_other_mul_div(other):
"""Conditions for other to satisfy before mul/div."""
if not isinstance(other, (u.Quantity, numbers.Number,
BaseUnitlessSpectrum, SourceSpectrum)):
raise exceptions.IncompatibleSources(
'Can only operate on... | def _validate_other_mul_div(other):
"""Conditions for other to satisfy before mul/div."""
if not isinstance(other, (u.Quantity, numbers.Number,
BaseUnitlessSpectrum, SourceSpectrum)):
raise exceptions.IncompatibleSources(
'Can only operate on... | [
"Conditions",
"for",
"other",
"to",
"satisfy",
"before",
"mul",
"/",
"div",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L375-L390 | [
"def",
"_validate_other_mul_div",
"(",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"(",
"u",
".",
"Quantity",
",",
"numbers",
".",
"Number",
",",
"BaseUnitlessSpectrum",
",",
"SourceSpectrum",
")",
")",
":",
"raise",
"exceptions",
".",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.integrate | Perform integration.
This uses any analytical integral that the
underlying model has (i.e., ``self.model.integral``).
If unavailable, it uses the default fall-back integrator
set in the ``default_integrator`` configuration item.
If wavelengths are provided, flux or throughput i... | synphot/spectrum.py | def integrate(self, wavelengths=None, **kwargs):
"""Perform integration.
This uses any analytical integral that the
underlying model has (i.e., ``self.model.integral``).
If unavailable, it uses the default fall-back integrator
set in the ``default_integrator`` configuration item... | def integrate(self, wavelengths=None, **kwargs):
"""Perform integration.
This uses any analytical integral that the
underlying model has (i.e., ``self.model.integral``).
If unavailable, it uses the default fall-back integrator
set in the ``default_integrator`` configuration item... | [
"Perform",
"integration",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L410-L493 | [
"def",
"integrate",
"(",
"self",
",",
"wavelengths",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Cannot integrate per Hz units natively across wavelength",
"# without converting them to per Angstrom unit first, so",
"# less misleading to just disallow that option for now.",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.avgwave | Calculate the :ref:`average wavelength <synphot-formula-avgwv>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
If `None`, `waveset` i... | synphot/spectrum.py | def avgwave(self, wavelengths=None):
"""Calculate the :ref:`average wavelength <synphot-formula-avgwv>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be... | def avgwave(self, wavelengths=None):
"""Calculate the :ref:`average wavelength <synphot-formula-avgwv>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be... | [
"Calculate",
"the",
":",
"ref",
":",
"average",
"wavelength",
"<synphot",
"-",
"formula",
"-",
"avgwv",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L495-L521 | [
"def",
"avgwave",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
".",
"value",
"y",
"=",
"self",
"(",
"x",
")",
".",
"value",
"num",
"=",
"np",
".",
"trapz",
"(",
"y"... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.barlam | Calculate :ref:`mean log wavelength <synphot-formula-barlam>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
If `None`, `waveset` is ... | synphot/spectrum.py | def barlam(self, wavelengths=None):
"""Calculate :ref:`mean log wavelength <synphot-formula-barlam>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in... | def barlam(self, wavelengths=None):
"""Calculate :ref:`mean log wavelength <synphot-formula-barlam>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in... | [
"Calculate",
":",
"ref",
":",
"mean",
"log",
"wavelength",
"<synphot",
"-",
"formula",
"-",
"barlam",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L523-L549 | [
"def",
"barlam",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
".",
"value",
"y",
"=",
"self",
"(",
"x",
")",
".",
"value",
"num",
"=",
"np",
".",
"trapz",
"(",
"y",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.pivot | Calculate :ref:`pivot wavelength <synphot-formula-pivwv>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
If `None`, `waveset` is used... | synphot/spectrum.py | def pivot(self, wavelengths=None):
"""Calculate :ref:`pivot wavelength <synphot-formula-pivwv>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angs... | def pivot(self, wavelengths=None):
"""Calculate :ref:`pivot wavelength <synphot-formula-pivwv>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angs... | [
"Calculate",
":",
"ref",
":",
"pivot",
"wavelength",
"<synphot",
"-",
"formula",
"-",
"pivwv",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L551-L577 | [
"def",
"pivot",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
".",
"value",
"y",
"=",
"self",
"(",
"x",
")",
".",
"value",
"num",
"=",
"np",
".",
"trapz",
"(",
"y",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.force_extrapolation | Force the underlying model to extrapolate.
An example where this is useful: You create a source spectrum
with non-default extrapolation behavior and you wish to force
the underlying empirical model to extrapolate based on nearest point.
.. note::
This is only applicable to... | synphot/spectrum.py | def force_extrapolation(self):
"""Force the underlying model to extrapolate.
An example where this is useful: You create a source spectrum
with non-default extrapolation behavior and you wish to force
the underlying empirical model to extrapolate based on nearest point.
.. note... | def force_extrapolation(self):
"""Force the underlying model to extrapolate.
An example where this is useful: You create a source spectrum
with non-default extrapolation behavior and you wish to force
the underlying empirical model to extrapolate based on nearest point.
.. note... | [
"Force",
"the",
"underlying",
"model",
"to",
"extrapolate",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L579-L606 | [
"def",
"force_extrapolation",
"(",
"self",
")",
":",
"# We use _model here in case the spectrum is redshifted.",
"if",
"isinstance",
"(",
"self",
".",
"_model",
",",
"Empirical1D",
")",
":",
"self",
".",
"_model",
".",
"fill_value",
"=",
"np",
".",
"nan",
"is_forc... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.taper | Taper the spectrum or bandpass.
The wavelengths to use for the first and last points are
calculated by using the same ratio as for the 2 interior points.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values ... | synphot/spectrum.py | def taper(self, wavelengths=None):
"""Taper the spectrum or bandpass.
The wavelengths to use for the first and last points are
calculated by using the same ratio as for the 2 interior points.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quant... | def taper(self, wavelengths=None):
"""Taper the spectrum or bandpass.
The wavelengths to use for the first and last points are
calculated by using the same ratio as for the 2 interior points.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quant... | [
"Taper",
"the",
"spectrum",
"or",
"bandpass",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L608-L657 | [
"def",
"taper",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
"# Calculate new end points for tapering",
"w1",
"=",
"x",
"[",
"0",
"]",
"**",
"2",
"/",
"x",
"[",
"1",
"]",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum._get_arrays | Get sampled spectrum or bandpass in user units. | synphot/spectrum.py | def _get_arrays(self, wavelengths, **kwargs):
"""Get sampled spectrum or bandpass in user units."""
x = self._validate_wavelengths(wavelengths)
y = self(x, **kwargs)
if isinstance(wavelengths, u.Quantity):
w = x.to(wavelengths.unit, u.spectral())
else:
w ... | def _get_arrays(self, wavelengths, **kwargs):
"""Get sampled spectrum or bandpass in user units."""
x = self._validate_wavelengths(wavelengths)
y = self(x, **kwargs)
if isinstance(wavelengths, u.Quantity):
w = x.to(wavelengths.unit, u.spectral())
else:
w ... | [
"Get",
"sampled",
"spectrum",
"or",
"bandpass",
"in",
"user",
"units",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L659-L669 | [
"def",
"_get_arrays",
"(",
"self",
",",
"wavelengths",
",",
"*",
"*",
"kwargs",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
"y",
"=",
"self",
"(",
"x",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(",
"wav... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum._do_plot | Plot worker.
Parameters
----------
x, y : `~astropy.units.quantity.Quantity`
Wavelength and flux/throughput to plot.
kwargs
See :func:`plot`. | synphot/spectrum.py | def _do_plot(x, y, title='', xlog=False, ylog=False,
left=None, right=None, bottom=None, top=None,
save_as=''): # pragma: no cover
"""Plot worker.
Parameters
----------
x, y : `~astropy.units.quantity.Quantity`
Wavelength and flux/throughpu... | def _do_plot(x, y, title='', xlog=False, ylog=False,
left=None, right=None, bottom=None, top=None,
save_as=''): # pragma: no cover
"""Plot worker.
Parameters
----------
x, y : `~astropy.units.quantity.Quantity`
Wavelength and flux/throughpu... | [
"Plot",
"worker",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L672-L732 | [
"def",
"_do_plot",
"(",
"x",
",",
"y",
",",
"title",
"=",
"''",
",",
"xlog",
"=",
"False",
",",
"ylog",
"=",
"False",
",",
"left",
"=",
"None",
",",
"right",
"=",
"None",
",",
"bottom",
"=",
"None",
",",
"top",
"=",
"None",
",",
"save_as",
"=",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSpectrum.plot | Plot the spectrum.
.. note:: Uses ``matplotlib``.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
If `None`, `waveset` is used... | synphot/spectrum.py | def plot(self, wavelengths=None, **kwargs): # pragma: no cover
"""Plot the spectrum.
.. note:: Uses ``matplotlib``.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Qu... | def plot(self, wavelengths=None, **kwargs): # pragma: no cover
"""Plot the spectrum.
.. note:: Uses ``matplotlib``.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Qu... | [
"Plot",
"the",
"spectrum",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L734-L774 | [
"def",
"plot",
"(",
"self",
",",
"wavelengths",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pragma: no cover",
"w",
",",
"y",
"=",
"self",
".",
"_get_arrays",
"(",
"wavelengths",
")",
"self",
".",
"_do_plot",
"(",
"w",
",",
"y",
",",
"*",
"*... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSourceSpectrum._validate_flux_unit | Make sure flux unit is valid. | synphot/spectrum.py | def _validate_flux_unit(new_unit, wav_only=False):
"""Make sure flux unit is valid."""
new_unit = units.validate_unit(new_unit)
acceptable_types = ['spectral flux density wav',
'photon flux density wav']
acceptable_names = ['PHOTLAM', 'FLAM']
if not w... | def _validate_flux_unit(new_unit, wav_only=False):
"""Make sure flux unit is valid."""
new_unit = units.validate_unit(new_unit)
acceptable_types = ['spectral flux density wav',
'photon flux density wav']
acceptable_names = ['PHOTLAM', 'FLAM']
if not w... | [
"Make",
"sure",
"flux",
"unit",
"is",
"valid",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L785-L802 | [
"def",
"_validate_flux_unit",
"(",
"new_unit",
",",
"wav_only",
"=",
"False",
")",
":",
"new_unit",
"=",
"units",
".",
"validate_unit",
"(",
"new_unit",
")",
"acceptable_types",
"=",
"[",
"'spectral flux density wav'",
",",
"'photon flux density wav'",
"]",
"accepta... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseSourceSpectrum.normalize | Renormalize the spectrum to the given Quantity and band.
.. warning::
Redshift attribute (``z``) is reset to 0 in the normalized
spectrum even if ``self.z`` is non-zero.
This is because the normalization simply adds a scale
factor to the existing composite model... | synphot/spectrum.py | def normalize(self, renorm_val, band=None, wavelengths=None, force=False,
area=None, vegaspec=None):
"""Renormalize the spectrum to the given Quantity and band.
.. warning::
Redshift attribute (``z``) is reset to 0 in the normalized
spectrum even if ``self.z``... | def normalize(self, renorm_val, band=None, wavelengths=None, force=False,
area=None, vegaspec=None):
"""Renormalize the spectrum to the given Quantity and band.
.. warning::
Redshift attribute (``z``) is reset to 0 in the normalized
spectrum even if ``self.z``... | [
"Renormalize",
"the",
"spectrum",
"to",
"the",
"given",
"Quantity",
"and",
"band",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L837-L995 | [
"def",
"normalize",
"(",
"self",
",",
"renorm_val",
",",
"band",
"=",
"None",
",",
"wavelengths",
"=",
"None",
",",
"force",
"=",
"False",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
")",
":",
"warndict",
"=",
"{",
"}",
"if",
"band",
"i... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum._process_flux_param | Process individual model parameter representing flux. | synphot/spectrum.py | def _process_flux_param(self, pval, wave):
"""Process individual model parameter representing flux."""
if isinstance(pval, u.Quantity):
self._validate_flux_unit(pval.unit)
outval = units.convert_flux(self._redshift_model(wave), pval,
self._... | def _process_flux_param(self, pval, wave):
"""Process individual model parameter representing flux."""
if isinstance(pval, u.Quantity):
self._validate_flux_unit(pval.unit)
outval = units.convert_flux(self._redshift_model(wave), pval,
self._... | [
"Process",
"individual",
"model",
"parameter",
"representing",
"flux",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1024-L1032 | [
"def",
"_process_flux_param",
"(",
"self",
",",
"pval",
",",
"wave",
")",
":",
"if",
"isinstance",
"(",
"pval",
",",
"u",
".",
"Quantity",
")",
":",
"self",
".",
"_validate_flux_unit",
"(",
"pval",
".",
"unit",
")",
"outval",
"=",
"units",
".",
"conver... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum.model | Model of the spectrum with given redshift. | synphot/spectrum.py | def model(self):
"""Model of the spectrum with given redshift."""
if self.z == 0:
m = self._model
else:
# wavelength
if self._internal_wave_unit.physical_type == 'length':
rs = self._redshift_model.inverse
# frequency or wavenumber
... | def model(self):
"""Model of the spectrum with given redshift."""
if self.z == 0:
m = self._model
else:
# wavelength
if self._internal_wave_unit.physical_type == 'length':
rs = self._redshift_model.inverse
# frequency or wavenumber
... | [
"Model",
"of",
"the",
"spectrum",
"with",
"given",
"redshift",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1035-L1054 | [
"def",
"model",
"(",
"self",
")",
":",
"if",
"self",
".",
"z",
"==",
"0",
":",
"m",
"=",
"self",
".",
"_model",
"else",
":",
"# wavelength",
"if",
"self",
".",
"_internal_wave_unit",
".",
"physical_type",
"==",
"'length'",
":",
"rs",
"=",
"self",
"."... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum.z | Change redshift. | synphot/spectrum.py | def z(self, what):
"""Change redshift."""
if not isinstance(what, numbers.Real):
raise exceptions.SynphotError(
'Redshift must be a real scalar number.')
self._z = float(what)
self._redshift_model = RedshiftScaleFactor(self._z)
if self.z_type == 'wavel... | def z(self, what):
"""Change redshift."""
if not isinstance(what, numbers.Real):
raise exceptions.SynphotError(
'Redshift must be a real scalar number.')
self._z = float(what)
self._redshift_model = RedshiftScaleFactor(self._z)
if self.z_type == 'wavel... | [
"Change",
"redshift",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1062-L1072 | [
"def",
"z",
"(",
"self",
",",
"what",
")",
":",
"if",
"not",
"isinstance",
"(",
"what",
",",
"numbers",
".",
"Real",
")",
":",
"raise",
"exceptions",
".",
"SynphotError",
"(",
"'Redshift must be a real scalar number.'",
")",
"self",
".",
"_z",
"=",
"float"... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum._validate_other_add_sub | Conditions for other to satisfy before add/sub. | synphot/spectrum.py | def _validate_other_add_sub(self, other):
"""Conditions for other to satisfy before add/sub."""
if not isinstance(other, self.__class__):
raise exceptions.IncompatibleSources(
'Can only operate on {0}.'.format(self.__class__.__name__)) | def _validate_other_add_sub(self, other):
"""Conditions for other to satisfy before add/sub."""
if not isinstance(other, self.__class__):
raise exceptions.IncompatibleSources(
'Can only operate on {0}.'.format(self.__class__.__name__)) | [
"Conditions",
"for",
"other",
"to",
"satisfy",
"before",
"add",
"/",
"sub",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1092-L1096 | [
"def",
"_validate_other_add_sub",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"raise",
"exceptions",
".",
"IncompatibleSources",
"(",
"'Can only operate on {0}.'",
".",
"format",
"(",
"... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum.plot | Plot the spectrum.
.. note:: Uses :mod:`matplotlib`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for integration.
If not a Quantity, assumed to be in Angstrom.
If `None`, ``self.wave... | synphot/spectrum.py | def plot(self, wavelengths=None, flux_unit=None, area=None, vegaspec=None,
**kwargs): # pragma: no cover
"""Plot the spectrum.
.. note:: Uses :mod:`matplotlib`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
... | def plot(self, wavelengths=None, flux_unit=None, area=None, vegaspec=None,
**kwargs): # pragma: no cover
"""Plot the spectrum.
.. note:: Uses :mod:`matplotlib`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
... | [
"Plot",
"the",
"spectrum",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1141-L1172 | [
"def",
"plot",
"(",
"self",
",",
"wavelengths",
"=",
"None",
",",
"flux_unit",
"=",
"None",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pragma: no cover",
"w",
",",
"y",
"=",
"self",
".",
"_get_arrays... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum.to_fits | Write the spectrum to a FITS file.
Parameters
----------
filename : str
Output filename.
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
... | synphot/spectrum.py | def to_fits(self, filename, wavelengths=None, flux_unit=None, area=None,
vegaspec=None, **kwargs):
"""Write the spectrum to a FITS file.
Parameters
----------
filename : str
Output filename.
wavelengths : array-like, `~astropy.units.quantity.Quantity... | def to_fits(self, filename, wavelengths=None, flux_unit=None, area=None,
vegaspec=None, **kwargs):
"""Write the spectrum to a FITS file.
Parameters
----------
filename : str
Output filename.
wavelengths : array-like, `~astropy.units.quantity.Quantity... | [
"Write",
"the",
"spectrum",
"to",
"a",
"FITS",
"file",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1174-L1214 | [
"def",
"to_fits",
"(",
"self",
",",
"filename",
",",
"wavelengths",
"=",
"None",
",",
"flux_unit",
"=",
"None",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"w",
",",
"y",
"=",
"self",
".",
"_get_arrays... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum.from_file | Create a spectrum from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Spectrum filename.
keep_neg : bool
See `~synphot.models.Empirical1D`.
kwargs :... | synphot/spectrum.py | def from_file(cls, filename, keep_neg=False, **kwargs):
"""Create a spectrum from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Spectrum filename.
keep_neg : bo... | def from_file(cls, filename, keep_neg=False, **kwargs):
"""Create a spectrum from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Spectrum filename.
keep_neg : bo... | [
"Create",
"a",
"spectrum",
"from",
"file",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1217-L1244 | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
",",
"keep_neg",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"header",
",",
"wavelengths",
",",
"fluxes",
"=",
"specio",
".",
"read_spec",
"(",
"filename",
",",
"*",
"*",
"kwargs",
")",
"return",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SourceSpectrum.from_vega | Load :ref:`Vega spectrum <synphot-vega-spec>`.
Parameters
----------
kwargs : dict
Keywords acceptable by :func:`~synphot.specio.read_remote_spec`.
Returns
-------
vegaspec : `SourceSpectrum`
Empirical Vega spectrum. | synphot/spectrum.py | def from_vega(cls, **kwargs):
"""Load :ref:`Vega spectrum <synphot-vega-spec>`.
Parameters
----------
kwargs : dict
Keywords acceptable by :func:`~synphot.specio.read_remote_spec`.
Returns
-------
vegaspec : `SourceSpectrum`
Empirical Veg... | def from_vega(cls, **kwargs):
"""Load :ref:`Vega spectrum <synphot-vega-spec>`.
Parameters
----------
kwargs : dict
Keywords acceptable by :func:`~synphot.specio.read_remote_spec`.
Returns
-------
vegaspec : `SourceSpectrum`
Empirical Veg... | [
"Load",
":",
"ref",
":",
"Vega",
"spectrum",
"<synphot",
"-",
"vega",
"-",
"spec",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1247-L1268 | [
"def",
"from_vega",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"filename",
"=",
"conf",
".",
"vega_file",
"header",
",",
"wavelengths",
",",
"fluxes",
"=",
"specio",
".",
"read_remote_spec",
"(",
"filename",
",",
"*",
"*",
"kwargs",
")",
"header",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | BaseUnitlessSpectrum._validate_flux_unit | Make sure flux unit is valid. | synphot/spectrum.py | def _validate_flux_unit(new_unit): # pragma: no cover
"""Make sure flux unit is valid."""
new_unit = units.validate_unit(new_unit)
if new_unit.decompose() != u.dimensionless_unscaled:
raise exceptions.SynphotError(
'Unit {0} is not dimensionless'.format(new_unit))
... | def _validate_flux_unit(new_unit): # pragma: no cover
"""Make sure flux unit is valid."""
new_unit = units.validate_unit(new_unit)
if new_unit.decompose() != u.dimensionless_unscaled:
raise exceptions.SynphotError(
'Unit {0} is not dimensionless'.format(new_unit))
... | [
"Make",
"sure",
"flux",
"unit",
"is",
"valid",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1280-L1288 | [
"def",
"_validate_flux_unit",
"(",
"new_unit",
")",
":",
"# pragma: no cover",
"new_unit",
"=",
"units",
".",
"validate_unit",
"(",
"new_unit",
")",
"if",
"new_unit",
".",
"decompose",
"(",
")",
"!=",
"u",
".",
"dimensionless_unscaled",
":",
"raise",
"exceptions... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.check_overlap | Check for wavelength overlap between two spectra.
Only wavelengths where ``self`` throughput is non-zero
are considered.
Example of full overlap::
|---------- other ----------|
|------ self ------|
Examples of partial overlap::
|---------- self... | synphot/spectrum.py | def check_overlap(self, other, wavelengths=None, threshold=0.01):
"""Check for wavelength overlap between two spectra.
Only wavelengths where ``self`` throughput is non-zero
are considered.
Example of full overlap::
|---------- other ----------|
|------ self... | def check_overlap(self, other, wavelengths=None, threshold=0.01):
"""Check for wavelength overlap between two spectra.
Only wavelengths where ``self`` throughput is non-zero
are considered.
Example of full overlap::
|---------- other ----------|
|------ self... | [
"Check",
"for",
"wavelength",
"overlap",
"between",
"two",
"spectra",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1333-L1448 | [
"def",
"check_overlap",
"(",
"self",
",",
"other",
",",
"wavelengths",
"=",
"None",
",",
"threshold",
"=",
"0.01",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"BaseSpectrum",
")",
":",
"raise",
"exceptions",
".",
"SynphotError",
"(",
"'other mu... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.unit_response | Calculate :ref:`unit response <synphot-formula-uresp>`
of this bandpass.
Parameters
----------
area : float or `~astropy.units.quantity.Quantity`
Area that flux covers. If not a Quantity, assumed to be in
:math:`cm^{2}`.
wavelengths : array-like, `~astro... | synphot/spectrum.py | def unit_response(self, area, wavelengths=None):
"""Calculate :ref:`unit response <synphot-formula-uresp>`
of this bandpass.
Parameters
----------
area : float or `~astropy.units.quantity.Quantity`
Area that flux covers. If not a Quantity, assumed to be in
... | def unit_response(self, area, wavelengths=None):
"""Calculate :ref:`unit response <synphot-formula-uresp>`
of this bandpass.
Parameters
----------
area : float or `~astropy.units.quantity.Quantity`
Area that flux covers. If not a Quantity, assumed to be in
... | [
"Calculate",
":",
"ref",
":",
"unit",
"response",
"<synphot",
"-",
"formula",
"-",
"uresp",
">",
"of",
"this",
"bandpass",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1450-L1481 | [
"def",
"unit_response",
"(",
"self",
",",
"area",
",",
"wavelengths",
"=",
"None",
")",
":",
"a",
"=",
"units",
".",
"validate_quantity",
"(",
"area",
",",
"units",
".",
"AREA",
")",
"# Only correct if wavelengths are in Angstrom.",
"x",
"=",
"self",
".",
"_... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.rmswidth | Calculate the :ref:`bandpass RMS width <synphot-formula-rmswidth>`.
Not to be confused with :func:`photbw`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to... | synphot/spectrum.py | def rmswidth(self, wavelengths=None, threshold=None):
"""Calculate the :ref:`bandpass RMS width <synphot-formula-rmswidth>`.
Not to be confused with :func:`photbw`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Waveleng... | def rmswidth(self, wavelengths=None, threshold=None):
"""Calculate the :ref:`bandpass RMS width <synphot-formula-rmswidth>`.
Not to be confused with :func:`photbw`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Waveleng... | [
"Calculate",
"the",
":",
"ref",
":",
"bandpass",
"RMS",
"width",
"<synphot",
"-",
"formula",
"-",
"rmswidth",
">",
".",
"Not",
"to",
"be",
"confused",
"with",
":",
"func",
":",
"photbw",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1483-L1536 | [
"def",
"rmswidth",
"(",
"self",
",",
"wavelengths",
"=",
"None",
",",
"threshold",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
".",
"value",
"y",
"=",
"self",
"(",
"x",
")",
".",
"value",
"if",
"thr... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.fwhm | Calculate :ref:`synphot-formula-fwhm` of equivalent gaussian.
Parameters
----------
kwargs : dict
See :func:`photbw`.
Returns
-------
fwhm_val : `~astropy.units.quantity.Quantity`
FWHM of equivalent gaussian. | synphot/spectrum.py | def fwhm(self, **kwargs):
"""Calculate :ref:`synphot-formula-fwhm` of equivalent gaussian.
Parameters
----------
kwargs : dict
See :func:`photbw`.
Returns
-------
fwhm_val : `~astropy.units.quantity.Quantity`
FWHM of equivalent gaussian.
... | def fwhm(self, **kwargs):
"""Calculate :ref:`synphot-formula-fwhm` of equivalent gaussian.
Parameters
----------
kwargs : dict
See :func:`photbw`.
Returns
-------
fwhm_val : `~astropy.units.quantity.Quantity`
FWHM of equivalent gaussian.
... | [
"Calculate",
":",
"ref",
":",
"synphot",
"-",
"formula",
"-",
"fwhm",
"of",
"equivalent",
"gaussian",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1600-L1614 | [
"def",
"fwhm",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"np",
".",
"sqrt",
"(",
"8",
"*",
"np",
".",
"log",
"(",
"2",
")",
")",
"*",
"self",
".",
"photbw",
"(",
"*",
"*",
"kwargs",
")"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.tpeak | Calculate :ref:`peak bandpass throughput <synphot-formula-tpeak>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
If `None`, ``self.wa... | synphot/spectrum.py | def tpeak(self, wavelengths=None):
"""Calculate :ref:`peak bandpass throughput <synphot-formula-tpeak>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be... | def tpeak(self, wavelengths=None):
"""Calculate :ref:`peak bandpass throughput <synphot-formula-tpeak>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be... | [
"Calculate",
":",
"ref",
":",
"peak",
"bandpass",
"throughput",
"<synphot",
"-",
"formula",
"-",
"tpeak",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1633-L1650 | [
"def",
"tpeak",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
".",
"value",
"return",
"self",
"(",
"x",
")",
".",
"max",
"(",
")"
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.wpeak | Calculate
:ref:`wavelength at peak throughput <synphot-formula-tpeak>`.
If there are multiple data points with peak throughput
value, only the first match is returned.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
... | synphot/spectrum.py | def wpeak(self, wavelengths=None):
"""Calculate
:ref:`wavelength at peak throughput <synphot-formula-tpeak>`.
If there are multiple data points with peak throughput
value, only the first match is returned.
Parameters
----------
wavelengths : array-like, `~astrop... | def wpeak(self, wavelengths=None):
"""Calculate
:ref:`wavelength at peak throughput <synphot-formula-tpeak>`.
If there are multiple data points with peak throughput
value, only the first match is returned.
Parameters
----------
wavelengths : array-like, `~astrop... | [
"Calculate",
":",
"ref",
":",
"wavelength",
"at",
"peak",
"throughput",
"<synphot",
"-",
"formula",
"-",
"tpeak",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1652-L1673 | [
"def",
"wpeak",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
"return",
"x",
"[",
"self",
"(",
"x",
")",
"==",
"self",
".",
"tpeak",
"(",
"wavelengths",
"=",
"wavelength... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.rectwidth | Calculate :ref:`bandpass rectangular width <synphot-formula-rectw>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
If `None`, ``self.... | synphot/spectrum.py | def rectwidth(self, wavelengths=None):
"""Calculate :ref:`bandpass rectangular width <synphot-formula-rectw>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed... | def rectwidth(self, wavelengths=None):
"""Calculate :ref:`bandpass rectangular width <synphot-formula-rectw>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed... | [
"Calculate",
":",
"ref",
":",
"bandpass",
"rectangular",
"width",
"<synphot",
"-",
"formula",
"-",
"rectw",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1693-L1717 | [
"def",
"rectwidth",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"equvw",
"=",
"self",
".",
"equivwidth",
"(",
"wavelengths",
"=",
"wavelengths",
")",
"tpeak",
"=",
"self",
".",
"tpeak",
"(",
"wavelengths",
"=",
"wavelengths",
")",
"if",
"tpea... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.efficiency | Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom.
If `None`, ``self.wa... | synphot/spectrum.py | def efficiency(self, wavelengths=None):
"""Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed ... | def efficiency(self, wavelengths=None):
"""Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed ... | [
"Calculate",
":",
"ref",
":",
"dimensionless",
"efficiency",
"<synphot",
"-",
"formula",
"-",
"qtlam",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1719-L1738 | [
"def",
"efficiency",
"(",
"self",
",",
"wavelengths",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_wavelengths",
"(",
"wavelengths",
")",
".",
"value",
"y",
"=",
"self",
"(",
"x",
")",
".",
"value",
"qtlam",
"=",
"abs",
"(",
"np",
".",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.emflx | Calculate
:ref:`equivalent monochromatic flux <synphot-formula-emflx>`.
Parameters
----------
area, wavelengths
See :func:`unit_response`.
Returns
-------
em_flux : `~astropy.units.quantity.Quantity`
Equivalent monochromatic flux. | synphot/spectrum.py | def emflx(self, area, wavelengths=None):
"""Calculate
:ref:`equivalent monochromatic flux <synphot-formula-emflx>`.
Parameters
----------
area, wavelengths
See :func:`unit_response`.
Returns
-------
em_flux : `~astropy.units.quantity.Quantity... | def emflx(self, area, wavelengths=None):
"""Calculate
:ref:`equivalent monochromatic flux <synphot-formula-emflx>`.
Parameters
----------
area, wavelengths
See :func:`unit_response`.
Returns
-------
em_flux : `~astropy.units.quantity.Quantity... | [
"Calculate",
":",
"ref",
":",
"equivalent",
"monochromatic",
"flux",
"<synphot",
"-",
"formula",
"-",
"emflx",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1740-L1764 | [
"def",
"emflx",
"(",
"self",
",",
"area",
",",
"wavelengths",
"=",
"None",
")",
":",
"t_lambda",
"=",
"self",
".",
"tlambda",
"(",
"wavelengths",
"=",
"wavelengths",
")",
"if",
"t_lambda",
"==",
"0",
":",
"# pragma: no cover",
"em_flux",
"=",
"0.0",
"*",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.from_file | Creates a bandpass from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Bandpass filename.
kwargs : dict
Keywords acceptable by
:func:`~synphot.sp... | synphot/spectrum.py | def from_file(cls, filename, **kwargs):
"""Creates a bandpass from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Bandpass filename.
kwargs : dict
Ke... | def from_file(cls, filename, **kwargs):
"""Creates a bandpass from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Bandpass filename.
kwargs : dict
Ke... | [
"Creates",
"a",
"bandpass",
"from",
"file",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1805-L1836 | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'flux_unit'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'flux_unit'",
"]",
"=",
"cls",
".",
"_internal_flux_unit",
"if",
"(",
"(",
"filename",
".",
"endswith",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SpectralElement.from_filter | Load :ref:`pre-defined filter bandpass <synphot-predefined-filter>`.
Parameters
----------
filtername : str
Filter name. Choose from 'bessel_j', 'bessel_h', 'bessel_k',
'cousins_r', 'cousins_i', 'johnson_u', 'johnson_b', 'johnson_v',
'johnson_r', 'johnson_i',... | synphot/spectrum.py | def from_filter(cls, filtername, **kwargs):
"""Load :ref:`pre-defined filter bandpass <synphot-predefined-filter>`.
Parameters
----------
filtername : str
Filter name. Choose from 'bessel_j', 'bessel_h', 'bessel_k',
'cousins_r', 'cousins_i', 'johnson_u', 'johnson... | def from_filter(cls, filtername, **kwargs):
"""Load :ref:`pre-defined filter bandpass <synphot-predefined-filter>`.
Parameters
----------
filtername : str
Filter name. Choose from 'bessel_j', 'bessel_h', 'bessel_k',
'cousins_r', 'cousins_i', 'johnson_u', 'johnson... | [
"Load",
":",
"ref",
":",
"pre",
"-",
"defined",
"filter",
"bandpass",
"<synphot",
"-",
"predefined",
"-",
"filter",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1839-L1909 | [
"def",
"from_filter",
"(",
"cls",
",",
"filtername",
",",
"*",
"*",
"kwargs",
")",
":",
"filtername",
"=",
"filtername",
".",
"lower",
"(",
")",
"# Select filename based on filter name",
"if",
"filtername",
"==",
"'bessel_j'",
":",
"cfgitem",
"=",
"Conf",
".",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ActivateScene.handle_frame | Handle incoming API frame, return True if this was the expected frame. | pyvlx/activate_scene.py | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameActivateSceneConfirmation) and frame.session_id == self.session_id:
if frame.status == ActivateSceneConfirmationStatus.ACCEPTED:
self.su... | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameActivateSceneConfirmation) and frame.session_id == self.session_id:
if frame.status == ActivateSceneConfirmationStatus.ACCEPTED:
self.su... | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/activate_scene.py#L21-L36 | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameActivateSceneConfirmation",
")",
"and",
"frame",
".",
"session_id",
"==",
"self",
".",
"session_id",
":",
"if",
"frame",
".",
"status",
"==",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | ActivateScene.request_frame | Construct initiating frame. | pyvlx/activate_scene.py | def request_frame(self):
"""Construct initiating frame."""
self.session_id = get_new_session_id()
return FrameActivateSceneRequest(scene_id=self.scene_id, session_id=self.session_id) | def request_frame(self):
"""Construct initiating frame."""
self.session_id = get_new_session_id()
return FrameActivateSceneRequest(scene_id=self.scene_id, session_id=self.session_id) | [
"Construct",
"initiating",
"frame",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/activate_scene.py#L38-L41 | [
"def",
"request_frame",
"(",
"self",
")",
":",
"self",
".",
"session_id",
"=",
"get_new_session_id",
"(",
")",
"return",
"FrameActivateSceneRequest",
"(",
"scene_id",
"=",
"self",
".",
"scene_id",
",",
"session_id",
"=",
"self",
".",
"session_id",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Observation._init_bins | Calculated binned wavelength centers, edges, and flux.
By contrast, the native waveset and flux should be considered
samples of a continuous function.
Thus, it makes sense to interpolate ``self.waveset`` and
``self(self.waveset)``, but not `binset` and `binflux`. | synphot/observation.py | def _init_bins(self, binset):
"""Calculated binned wavelength centers, edges, and flux.
By contrast, the native waveset and flux should be considered
samples of a continuous function.
Thus, it makes sense to interpolate ``self.waveset`` and
``self(self.waveset)``, but not `bins... | def _init_bins(self, binset):
"""Calculated binned wavelength centers, edges, and flux.
By contrast, the native waveset and flux should be considered
samples of a continuous function.
Thus, it makes sense to interpolate ``self.waveset`` and
``self(self.waveset)``, but not `bins... | [
"Calculated",
"binned",
"wavelength",
"centers",
"edges",
"and",
"flux",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L142-L196 | [
"def",
"_init_bins",
"(",
"self",
",",
"binset",
")",
":",
"if",
"binset",
"is",
"None",
":",
"if",
"self",
".",
"bandpass",
".",
"waveset",
"is",
"not",
"None",
":",
"self",
".",
"_binset",
"=",
"self",
".",
"bandpass",
".",
"waveset",
"elif",
"self... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.sample_binned | Sample binned observation without interpolation.
To sample unbinned data, use ``__call__``.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.
If not a Quantity, assumed to be in Angstrom... | synphot/observation.py | def sample_binned(self, wavelengths=None, flux_unit=None, **kwargs):
"""Sample binned observation without interpolation.
To sample unbinned data, use ``__call__``.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Waveleng... | def sample_binned(self, wavelengths=None, flux_unit=None, **kwargs):
"""Sample binned observation without interpolation.
To sample unbinned data, use ``__call__``.
Parameters
----------
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Waveleng... | [
"Sample",
"binned",
"observation",
"without",
"interpolation",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L241-L283 | [
"def",
"sample_binned",
"(",
"self",
",",
"wavelengths",
"=",
"None",
",",
"flux_unit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"x",
"=",
"self",
".",
"_validate_binned_wavelengths",
"(",
"wavelengths",
")",
"i",
"=",
"np",
".",
"searchsorted",
"... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation._get_binned_arrays | Get binned observation in user units. | synphot/observation.py | def _get_binned_arrays(self, wavelengths, flux_unit, area=None,
vegaspec=None):
"""Get binned observation in user units."""
x = self._validate_binned_wavelengths(wavelengths)
y = self.sample_binned(wavelengths=x, flux_unit=flux_unit, area=area,
... | def _get_binned_arrays(self, wavelengths, flux_unit, area=None,
vegaspec=None):
"""Get binned observation in user units."""
x = self._validate_binned_wavelengths(wavelengths)
y = self.sample_binned(wavelengths=x, flux_unit=flux_unit, area=area,
... | [
"Get",
"binned",
"observation",
"in",
"user",
"units",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L285-L297 | [
"def",
"_get_binned_arrays",
"(",
"self",
",",
"wavelengths",
",",
"flux_unit",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"_validate_binned_wavelengths",
"(",
"wavelengths",
")",
"y",
"=",
"self",
".",
"sample... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.binned_waverange | Calculate the wavelength range covered by the given number
of pixels centered on the given central wavelengths of
`binset`.
Parameters
----------
cenwave : float or `~astropy.units.quantity.Quantity`
Desired central wavelength.
If not a Quantity, assumed ... | synphot/observation.py | def binned_waverange(self, cenwave, npix, **kwargs):
"""Calculate the wavelength range covered by the given number
of pixels centered on the given central wavelengths of
`binset`.
Parameters
----------
cenwave : float or `~astropy.units.quantity.Quantity`
Des... | def binned_waverange(self, cenwave, npix, **kwargs):
"""Calculate the wavelength range covered by the given number
of pixels centered on the given central wavelengths of
`binset`.
Parameters
----------
cenwave : float or `~astropy.units.quantity.Quantity`
Des... | [
"Calculate",
"the",
"wavelength",
"range",
"covered",
"by",
"the",
"given",
"number",
"of",
"pixels",
"centered",
"on",
"the",
"given",
"central",
"wavelengths",
"of",
"binset",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L299-L331 | [
"def",
"binned_waverange",
"(",
"self",
",",
"cenwave",
",",
"npix",
",",
"*",
"*",
"kwargs",
")",
":",
"# Calculation is done in the unit of cenwave.",
"if",
"not",
"isinstance",
"(",
"cenwave",
",",
"u",
".",
"Quantity",
")",
":",
"cenwave",
"=",
"cenwave",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.binned_pixelrange | Calculate the number of pixels within the given wavelength
range and `binset`.
Parameters
----------
waverange : tuple of float or `~astropy.units.quantity.Quantity`
Lower and upper limits of the desired wavelength range.
If not a Quantity, assumed to be in Angst... | synphot/observation.py | def binned_pixelrange(self, waverange, **kwargs):
"""Calculate the number of pixels within the given wavelength
range and `binset`.
Parameters
----------
waverange : tuple of float or `~astropy.units.quantity.Quantity`
Lower and upper limits of the desired wavelength... | def binned_pixelrange(self, waverange, **kwargs):
"""Calculate the number of pixels within the given wavelength
range and `binset`.
Parameters
----------
waverange : tuple of float or `~astropy.units.quantity.Quantity`
Lower and upper limits of the desired wavelength... | [
"Calculate",
"the",
"number",
"of",
"pixels",
"within",
"the",
"given",
"wavelength",
"range",
"and",
"binset",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L333-L354 | [
"def",
"binned_pixelrange",
"(",
"self",
",",
"waverange",
",",
"*",
"*",
"kwargs",
")",
":",
"x",
"=",
"units",
".",
"validate_quantity",
"(",
"waverange",
",",
"self",
".",
"_internal_wave_unit",
",",
"equivalencies",
"=",
"u",
".",
"spectral",
"(",
")",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.effective_wavelength | Calculate :ref:`effective wavelength <synphot-formula-effwave>`.
Parameters
----------
binned : bool
Sample data in native wavelengths if `False`.
Else, sample binned data (default).
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
... | synphot/observation.py | def effective_wavelength(self, binned=True, wavelengths=None,
mode='efflerg'):
"""Calculate :ref:`effective wavelength <synphot-formula-effwave>`.
Parameters
----------
binned : bool
Sample data in native wavelengths if `False`.
Else,... | def effective_wavelength(self, binned=True, wavelengths=None,
mode='efflerg'):
"""Calculate :ref:`effective wavelength <synphot-formula-effwave>`.
Parameters
----------
binned : bool
Sample data in native wavelengths if `False`.
Else,... | [
"Calculate",
":",
"ref",
":",
"effective",
"wavelength",
"<synphot",
"-",
"formula",
"-",
"effwave",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L356-L415 | [
"def",
"effective_wavelength",
"(",
"self",
",",
"binned",
"=",
"True",
",",
"wavelengths",
"=",
"None",
",",
"mode",
"=",
"'efflerg'",
")",
":",
"mode",
"=",
"mode",
".",
"lower",
"(",
")",
"if",
"mode",
"==",
"'efflerg'",
":",
"flux_unit",
"=",
"unit... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.effstim | Calculate :ref:`effective stimulus <synphot-formula-effstim>`
for given flux unit.
Parameters
----------
flux_unit : str or `~astropy.units.core.Unit` or `None`
The unit of effective stimulus.
COUNT gives result in count/s (see :meth:`countrate` for more
... | synphot/observation.py | def effstim(self, flux_unit=None, wavelengths=None, area=None,
vegaspec=None):
"""Calculate :ref:`effective stimulus <synphot-formula-effstim>`
for given flux unit.
Parameters
----------
flux_unit : str or `~astropy.units.core.Unit` or `None`
The unit... | def effstim(self, flux_unit=None, wavelengths=None, area=None,
vegaspec=None):
"""Calculate :ref:`effective stimulus <synphot-formula-effstim>`
for given flux unit.
Parameters
----------
flux_unit : str or `~astropy.units.core.Unit` or `None`
The unit... | [
"Calculate",
":",
"ref",
":",
"effective",
"stimulus",
"<synphot",
"-",
"formula",
"-",
"effstim",
">",
"for",
"given",
"flux",
"unit",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L418-L505 | [
"def",
"effstim",
"(",
"self",
",",
"flux_unit",
"=",
"None",
",",
"wavelengths",
"=",
"None",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
")",
":",
"if",
"flux_unit",
"is",
"None",
":",
"flux_unit",
"=",
"self",
".",
"_internal_flux_unit",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.countrate | Calculate :ref:`effective stimulus <synphot-formula-effstim>`
in count/s.
Parameters
----------
area : float or `~astropy.units.quantity.Quantity`
Area that flux covers. If not a Quantity, assumed to be in
:math:`cm^{2}`.
binned : bool
Sample... | synphot/observation.py | def countrate(self, area, binned=True, wavelengths=None, waverange=None,
force=False):
"""Calculate :ref:`effective stimulus <synphot-formula-effstim>`
in count/s.
Parameters
----------
area : float or `~astropy.units.quantity.Quantity`
Area that fl... | def countrate(self, area, binned=True, wavelengths=None, waverange=None,
force=False):
"""Calculate :ref:`effective stimulus <synphot-formula-effstim>`
in count/s.
Parameters
----------
area : float or `~astropy.units.quantity.Quantity`
Area that fl... | [
"Calculate",
":",
"ref",
":",
"effective",
"stimulus",
"<synphot",
"-",
"formula",
"-",
"effstim",
">",
"in",
"count",
"/",
"s",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L507-L614 | [
"def",
"countrate",
"(",
"self",
",",
"area",
",",
"binned",
"=",
"True",
",",
"wavelengths",
"=",
"None",
",",
"waverange",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"# Sample the observation",
"if",
"binned",
":",
"x",
"=",
"self",
".",
"_va... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.plot | Plot the observation.
.. note:: Uses ``matplotlib``.
Parameters
----------
binned : bool
Plot data in native wavelengths if `False`.
Else, plot binned data (default).
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wa... | synphot/observation.py | def plot(self, binned=True, wavelengths=None, flux_unit=None, area=None,
vegaspec=None, **kwargs): # pragma: no cover
"""Plot the observation.
.. note:: Uses ``matplotlib``.
Parameters
----------
binned : bool
Plot data in native wavelengths if `False`... | def plot(self, binned=True, wavelengths=None, flux_unit=None, area=None,
vegaspec=None, **kwargs): # pragma: no cover
"""Plot the observation.
.. note:: Uses ``matplotlib``.
Parameters
----------
binned : bool
Plot data in native wavelengths if `False`... | [
"Plot",
"the",
"observation",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L616-L656 | [
"def",
"plot",
"(",
"self",
",",
"binned",
"=",
"True",
",",
"wavelengths",
"=",
"None",
",",
"flux_unit",
"=",
"None",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pragma: no cover",
"if",
"binned",
"... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | Observation.as_spectrum | Reduce the observation to an empirical source spectrum.
An observation is a complex object with some restrictions
on its capabilities. At times, it would be useful to work
with the observation as a simple object that is easier to
manipulate and takes up less memory.
This is als... | synphot/observation.py | def as_spectrum(self, binned=True, wavelengths=None):
"""Reduce the observation to an empirical source spectrum.
An observation is a complex object with some restrictions
on its capabilities. At times, it would be useful to work
with the observation as a simple object that is easier to
... | def as_spectrum(self, binned=True, wavelengths=None):
"""Reduce the observation to an empirical source spectrum.
An observation is a complex object with some restrictions
on its capabilities. At times, it would be useful to work
with the observation as a simple object that is easier to
... | [
"Reduce",
"the",
"observation",
"to",
"an",
"empirical",
"source",
"spectrum",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L658-L696 | [
"def",
"as_spectrum",
"(",
"self",
",",
"binned",
"=",
"True",
",",
"wavelengths",
"=",
"None",
")",
":",
"if",
"binned",
":",
"w",
",",
"y",
"=",
"self",
".",
"_get_binned_arrays",
"(",
"wavelengths",
",",
"self",
".",
"_internal_flux_unit",
")",
"else"... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | SetNodeName.handle_frame | Handle incoming API frame, return True if this was the expected frame. | pyvlx/set_node_name.py | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameSetNodeNameConfirmation):
return False
self.success = frame.status == SetNodeNameConfirmationStatus.OK
return True | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameSetNodeNameConfirmation):
return False
self.success = frame.status == SetNodeNameConfirmationStatus.OK
return True | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/set_node_name.py#L18-L23 | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameSetNodeNameConfirmation",
")",
":",
"return",
"False",
"self",
".",
"success",
"=",
"frame",
".",
"status",
"==",
"SetNodeNameConfirmationS... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | ApiEvent.do_api_call | Start. Sending and waiting for answer. | pyvlx/api_event.py | async def do_api_call(self):
"""Start. Sending and waiting for answer."""
self.pyvlx.connection.register_frame_received_cb(
self.response_rec_callback)
await self.send_frame()
await self.start_timeout()
await self.response_received_or_timeout.wait()
await self... | async def do_api_call(self):
"""Start. Sending and waiting for answer."""
self.pyvlx.connection.register_frame_received_cb(
self.response_rec_callback)
await self.send_frame()
await self.start_timeout()
await self.response_received_or_timeout.wait()
await self... | [
"Start",
".",
"Sending",
"and",
"waiting",
"for",
"answer",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/api_event.py#L18-L26 | [
"async",
"def",
"do_api_call",
"(",
"self",
")",
":",
"self",
".",
"pyvlx",
".",
"connection",
".",
"register_frame_received_cb",
"(",
"self",
".",
"response_rec_callback",
")",
"await",
"self",
".",
"send_frame",
"(",
")",
"await",
"self",
".",
"start_timeout... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | ApiEvent.start_timeout | Start timeout. | pyvlx/api_event.py | async def start_timeout(self):
"""Start timeout."""
self.timeout_handle = self.pyvlx.connection.loop.call_later(
self.timeout_in_seconds, self.timeout) | async def start_timeout(self):
"""Start timeout."""
self.timeout_handle = self.pyvlx.connection.loop.call_later(
self.timeout_in_seconds, self.timeout) | [
"Start",
"timeout",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/api_event.py#L49-L52 | [
"async",
"def",
"start_timeout",
"(",
"self",
")",
":",
"self",
".",
"timeout_handle",
"=",
"self",
".",
"pyvlx",
".",
"connection",
".",
"loop",
".",
"call_later",
"(",
"self",
".",
"timeout_in_seconds",
",",
"self",
".",
"timeout",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | main | Load devices and scenes, run first scene. | old_api/examples/example.py | async def main():
"""Load devices and scenes, run first scene."""
pyvlx = PyVLX('pyvlx.yaml')
# Alternative:
# pyvlx = PyVLX(host="192.168.2.127", password="velux123", timeout=60)
await pyvlx.load_devices()
print(pyvlx.devices[1])
print(pyvlx.devices['Fenster 4'])
await pyvlx.load_scen... | async def main():
"""Load devices and scenes, run first scene."""
pyvlx = PyVLX('pyvlx.yaml')
# Alternative:
# pyvlx = PyVLX(host="192.168.2.127", password="velux123", timeout=60)
await pyvlx.load_devices()
print(pyvlx.devices[1])
print(pyvlx.devices['Fenster 4'])
await pyvlx.load_scen... | [
"Load",
"devices",
"and",
"scenes",
"run",
"first",
"scene",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/examples/example.py#L6-L23 | [
"async",
"def",
"main",
"(",
")",
":",
"pyvlx",
"=",
"PyVLX",
"(",
"'pyvlx.yaml'",
")",
"# Alternative:",
"# pyvlx = PyVLX(host=\"192.168.2.127\", password=\"velux123\", timeout=60)",
"await",
"pyvlx",
".",
"load_devices",
"(",
")",
"print",
"(",
"pyvlx",
".",
"device... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | OnOffSwitch.set_state | Set switch to desired state. | pyvlx/on_off_switch.py | async def set_state(self, parameter):
"""Set switch to desired state."""
command_send = CommandSend(pyvlx=self.pyvlx, node_id=self.node_id, parameter=parameter)
await command_send.do_api_call()
if not command_send.success:
raise PyVLXException("Unable to send command")
... | async def set_state(self, parameter):
"""Set switch to desired state."""
command_send = CommandSend(pyvlx=self.pyvlx, node_id=self.node_id, parameter=parameter)
await command_send.do_api_call()
if not command_send.success:
raise PyVLXException("Unable to send command")
... | [
"Set",
"switch",
"to",
"desired",
"state",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/on_off_switch.py#L16-L23 | [
"async",
"def",
"set_state",
"(",
"self",
",",
"parameter",
")",
":",
"command_send",
"=",
"CommandSend",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
",",
"node_id",
"=",
"self",
".",
"node_id",
",",
"parameter",
"=",
"parameter",
")",
"await",
"command_send"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | etau_madau | Madau 1995 extinction for a galaxy at given redshift.
This is the Lyman-alpha prescription from the photo-z code BPZ.
The Lyman-alpha forest approximately has an effective
"throughput" which is a function of redshift and
rest-frame wavelength.
One would multiply the SEDs by this factor before
p... | synphot/reddening.py | def etau_madau(wave, z, **kwargs):
"""Madau 1995 extinction for a galaxy at given redshift.
This is the Lyman-alpha prescription from the photo-z code BPZ.
The Lyman-alpha forest approximately has an effective
"throughput" which is a function of redshift and
rest-frame wavelength.
One would mul... | def etau_madau(wave, z, **kwargs):
"""Madau 1995 extinction for a galaxy at given redshift.
This is the Lyman-alpha prescription from the photo-z code BPZ.
The Lyman-alpha forest approximately has an effective
"throughput" which is a function of redshift and
rest-frame wavelength.
One would mul... | [
"Madau",
"1995",
"extinction",
"for",
"a",
"galaxy",
"at",
"given",
"redshift",
".",
"This",
"is",
"the",
"Lyman",
"-",
"alpha",
"prescription",
"from",
"the",
"photo",
"-",
"z",
"code",
"BPZ",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L244-L315 | [
"def",
"etau_madau",
"(",
"wave",
",",
"z",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"z",
",",
"numbers",
".",
"Real",
")",
":",
"raise",
"exceptions",
".",
"SynphotError",
"(",
"'Redshift must be a real scalar number.'",
")",
"if... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ReddeningLaw.extinction_curve | Generate extinction curve.
.. math::
A(V) = R(V) \\; \\times \\; E(B-V)
THRU = 10^{-0.4 \\; A(V)}
Parameters
----------
ebv : float or `~astropy.units.quantity.Quantity`
:math:`E(B-V)` value in magnitude.
wavelengths : array-like, `~astrop... | synphot/reddening.py | def extinction_curve(self, ebv, wavelengths=None):
"""Generate extinction curve.
.. math::
A(V) = R(V) \\; \\times \\; E(B-V)
THRU = 10^{-0.4 \\; A(V)}
Parameters
----------
ebv : float or `~astropy.units.quantity.Quantity`
:math:`E(B-V)` v... | def extinction_curve(self, ebv, wavelengths=None):
"""Generate extinction curve.
.. math::
A(V) = R(V) \\; \\times \\; E(B-V)
THRU = 10^{-0.4 \\; A(V)}
Parameters
----------
ebv : float or `~astropy.units.quantity.Quantity`
:math:`E(B-V)` v... | [
"Generate",
"extinction",
"curve",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L42-L84 | [
"def",
"extinction_curve",
"(",
"self",
",",
"ebv",
",",
"wavelengths",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"ebv",
",",
"u",
".",
"Quantity",
")",
"and",
"ebv",
".",
"unit",
".",
"decompose",
"(",
")",
"==",
"u",
".",
"mag",
":",
"ebv",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ReddeningLaw.to_fits | Write the reddening law to a FITS file.
:math:`R(V)` column is automatically named 'Av/E(B-V)'.
Parameters
----------
filename : str
Output filename.
wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None`
Wavelength values for sampling.... | synphot/reddening.py | def to_fits(self, filename, wavelengths=None, **kwargs):
"""Write the reddening law to a FITS file.
:math:`R(V)` column is automatically named 'Av/E(B-V)'.
Parameters
----------
filename : str
Output filename.
wavelengths : array-like, `~astropy.units.quant... | def to_fits(self, filename, wavelengths=None, **kwargs):
"""Write the reddening law to a FITS file.
:math:`R(V)` column is automatically named 'Av/E(B-V)'.
Parameters
----------
filename : str
Output filename.
wavelengths : array-like, `~astropy.units.quant... | [
"Write",
"the",
"reddening",
"law",
"to",
"a",
"FITS",
"file",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L86-L128 | [
"def",
"to_fits",
"(",
"self",
",",
"filename",
",",
"wavelengths",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"w",
",",
"y",
"=",
"self",
".",
"_get_arrays",
"(",
"wavelengths",
")",
"kwargs",
"[",
"'flux_col'",
"]",
"=",
"'Av/E(B-V)'",
"kwargs",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ReddeningLaw.from_file | Create a reddening law from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Reddening law filename.
kwargs : dict
Keywords acceptable by
:func:`~s... | synphot/reddening.py | def from_file(cls, filename, **kwargs):
"""Create a reddening law from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Reddening law filename.
kwargs : dict
... | def from_file(cls, filename, **kwargs):
"""Create a reddening law from file.
If filename has 'fits' or 'fit' suffix, it is read as FITS.
Otherwise, it is read as ASCII.
Parameters
----------
filename : str
Reddening law filename.
kwargs : dict
... | [
"Create",
"a",
"reddening",
"law",
"from",
"file",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L131-L163 | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'flux_unit'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'flux_unit'",
"]",
"=",
"cls",
".",
"_internal_flux_unit",
"if",
"(",
"(",
"filename",
".",
"endswith",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | ReddeningLaw.from_extinction_model | Load :ref:`pre-defined extinction model <synphot_reddening>`.
Parameters
----------
modelname : str
Extinction model name. Choose from 'lmc30dor', 'lmcavg', 'mwavg',
'mwdense', 'mwrv21', 'mwrv40', 'smcbar', or 'xgalsb'.
kwargs : dict
Keywords accepta... | synphot/reddening.py | def from_extinction_model(cls, modelname, **kwargs):
"""Load :ref:`pre-defined extinction model <synphot_reddening>`.
Parameters
----------
modelname : str
Extinction model name. Choose from 'lmc30dor', 'lmcavg', 'mwavg',
'mwdense', 'mwrv21', 'mwrv40', 'smcbar', ... | def from_extinction_model(cls, modelname, **kwargs):
"""Load :ref:`pre-defined extinction model <synphot_reddening>`.
Parameters
----------
modelname : str
Extinction model name. Choose from 'lmc30dor', 'lmcavg', 'mwavg',
'mwdense', 'mwrv21', 'mwrv40', 'smcbar', ... | [
"Load",
":",
"ref",
":",
"pre",
"-",
"defined",
"extinction",
"model",
"<synphot_reddening",
">",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L166-L227 | [
"def",
"from_extinction_model",
"(",
"cls",
",",
"modelname",
",",
"*",
"*",
"kwargs",
")",
":",
"modelname",
"=",
"modelname",
".",
"lower",
"(",
")",
"# Select filename based on model name",
"if",
"modelname",
"==",
"'lmc30dor'",
":",
"cfgitem",
"=",
"Conf",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | GetVersion.handle_frame | Handle incoming API frame, return True if this was the expected frame. | pyvlx/get_version.py | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameGetVersionConfirmation):
return False
self.version = frame.version
self.success = True
return True | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameGetVersionConfirmation):
return False
self.version = frame.version
self.success = True
return True | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_version.py#L15-L21 | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameGetVersionConfirmation",
")",
":",
"return",
"False",
"self",
".",
"version",
"=",
"frame",
".",
"version",
"self",
".",
"success",
"="... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameBase.validate_payload_len | Validate payload len. | pyvlx/frames/frame.py | def validate_payload_len(self, payload):
"""Validate payload len."""
if not hasattr(self, "PAYLOAD_LEN"):
# No fixed payload len, e.g. within FrameGetSceneListNotification
return
# pylint: disable=no-member
if len(payload) != self.PAYLOAD_LEN:
raise Py... | def validate_payload_len(self, payload):
"""Validate payload len."""
if not hasattr(self, "PAYLOAD_LEN"):
# No fixed payload len, e.g. within FrameGetSceneListNotification
return
# pylint: disable=no-member
if len(payload) != self.PAYLOAD_LEN:
raise Py... | [
"Validate",
"payload",
"len",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame.py#L22-L29 | [
"def",
"validate_payload_len",
"(",
"self",
",",
"payload",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"PAYLOAD_LEN\"",
")",
":",
"# No fixed payload len, e.g. within FrameGetSceneListNotification",
"return",
"# pylint: disable=no-member",
"if",
"len",
"(",
"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameBase.build_frame | Build raw bytes from command and payload. | pyvlx/frames/frame.py | def build_frame(command, payload):
"""Build raw bytes from command and payload."""
packet_length = 2 + len(payload) + 1
ret = struct.pack("BB", 0, packet_length)
ret += struct.pack(">H", command.value)
ret += payload
ret += struct.pack("B", calc_crc(ret))
return r... | def build_frame(command, payload):
"""Build raw bytes from command and payload."""
packet_length = 2 + len(payload) + 1
ret = struct.pack("BB", 0, packet_length)
ret += struct.pack(">H", command.value)
ret += payload
ret += struct.pack("B", calc_crc(ret))
return r... | [
"Build",
"raw",
"bytes",
"from",
"command",
"and",
"payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame.py#L45-L52 | [
"def",
"build_frame",
"(",
"command",
",",
"payload",
")",
":",
"packet_length",
"=",
"2",
"+",
"len",
"(",
"payload",
")",
"+",
"1",
"ret",
"=",
"struct",
".",
"pack",
"(",
"\"BB\"",
",",
"0",
",",
"packet_length",
")",
"ret",
"+=",
"struct",
".",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Scene.run | Run scene.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position. | pyvlx/scene.py | async def run(self, wait_for_completion=True):
"""Run scene.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
activate_scene = ActivateScene(
pyvlx=self.pyvlx,
wait_for_comp... | async def run(self, wait_for_completion=True):
"""Run scene.
Parameters:
* wait_for_completion: If set, function will return
after device has reached target position.
"""
activate_scene = ActivateScene(
pyvlx=self.pyvlx,
wait_for_comp... | [
"Run",
"scene",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/scene.py#L23-L37 | [
"async",
"def",
"run",
"(",
"self",
",",
"wait_for_completion",
"=",
"True",
")",
":",
"activate_scene",
"=",
"ActivateScene",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
",",
"wait_for_completion",
"=",
"wait_for_completion",
",",
"scene_id",
"=",
"self",
".",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Scenes.add | Add scene. | old_api/pyvlx/scenes.py | def add(self, scene):
"""Add scene."""
if not isinstance(scene, Scene):
raise TypeError()
self.__scenes.append(scene) | def add(self, scene):
"""Add scene."""
if not isinstance(scene, Scene):
raise TypeError()
self.__scenes.append(scene) | [
"Add",
"scene",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L33-L37 | [
"def",
"add",
"(",
"self",
",",
"scene",
")",
":",
"if",
"not",
"isinstance",
"(",
"scene",
",",
"Scene",
")",
":",
"raise",
"TypeError",
"(",
")",
"self",
".",
"__scenes",
".",
"append",
"(",
"scene",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Scenes.load | Load scenes from KLF 200. | old_api/pyvlx/scenes.py | async def load(self):
"""Load scenes from KLF 200."""
json_response = await self.pyvlx.interface.api_call('scenes', 'get')
self.data_import(json_response) | async def load(self):
"""Load scenes from KLF 200."""
json_response = await self.pyvlx.interface.api_call('scenes', 'get')
self.data_import(json_response) | [
"Load",
"scenes",
"from",
"KLF",
"200",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L39-L42 | [
"async",
"def",
"load",
"(",
"self",
")",
":",
"json_response",
"=",
"await",
"self",
".",
"pyvlx",
".",
"interface",
".",
"api_call",
"(",
"'scenes'",
",",
"'get'",
")",
"self",
".",
"data_import",
"(",
"json_response",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Scenes.data_import | Import scenes from JSON response. | old_api/pyvlx/scenes.py | def data_import(self, json_response):
"""Import scenes from JSON response."""
if 'data' not in json_response:
raise PyVLXException('no element data found: {0}'.format(
json.dumps(json_response)))
data = json_response['data']
for item in data:
self.... | def data_import(self, json_response):
"""Import scenes from JSON response."""
if 'data' not in json_response:
raise PyVLXException('no element data found: {0}'.format(
json.dumps(json_response)))
data = json_response['data']
for item in data:
self.... | [
"Import",
"scenes",
"from",
"JSON",
"response",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L44-L51 | [
"def",
"data_import",
"(",
"self",
",",
"json_response",
")",
":",
"if",
"'data'",
"not",
"in",
"json_response",
":",
"raise",
"PyVLXException",
"(",
"'no element data found: {0}'",
".",
"format",
"(",
"json",
".",
"dumps",
"(",
"json_response",
")",
")",
")",... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Scenes.load_scene | Load scene from json. | old_api/pyvlx/scenes.py | def load_scene(self, item):
"""Load scene from json."""
scene = Scene.from_config(self.pyvlx, item)
self.add(scene) | def load_scene(self, item):
"""Load scene from json."""
scene = Scene.from_config(self.pyvlx, item)
self.add(scene) | [
"Load",
"scene",
"from",
"json",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L53-L56 | [
"def",
"load_scene",
"(",
"self",
",",
"item",
")",
":",
"scene",
"=",
"Scene",
".",
"from_config",
"(",
"self",
".",
"pyvlx",
",",
"item",
")",
"self",
".",
"add",
"(",
"scene",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | GetState.handle_frame | Handle incoming API frame, return True if this was the expected frame. | pyvlx/get_state.py | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameGetStateConfirmation):
return False
self.success = True
self.gateway_state = frame.gateway_state
self.gateway_sub_state = fr... | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameGetStateConfirmation):
return False
self.success = True
self.gateway_state = frame.gateway_state
self.gateway_sub_state = fr... | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_state.py#L16-L23 | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameGetStateConfirmation",
")",
":",
"return",
"False",
"self",
".",
"success",
"=",
"True",
"self",
".",
"gateway_state",
"=",
"frame",
".... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | AliasArray.parse_raw | Parse alias array from raw bytes. | pyvlx/alias_array.py | def parse_raw(self, raw):
"""Parse alias array from raw bytes."""
if not isinstance(raw, bytes):
raise PyVLXException("AliasArray::invalid_type_if_raw", type_raw=type(raw))
if len(raw) != 21:
raise PyVLXException("AliasArray::invalid_size", size=len(raw))
nbr_of_a... | def parse_raw(self, raw):
"""Parse alias array from raw bytes."""
if not isinstance(raw, bytes):
raise PyVLXException("AliasArray::invalid_type_if_raw", type_raw=type(raw))
if len(raw) != 21:
raise PyVLXException("AliasArray::invalid_size", size=len(raw))
nbr_of_a... | [
"Parse",
"alias",
"array",
"from",
"raw",
"bytes",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/alias_array.py#L26-L36 | [
"def",
"parse_raw",
"(",
"self",
",",
"raw",
")",
":",
"if",
"not",
"isinstance",
"(",
"raw",
",",
"bytes",
")",
":",
"raise",
"PyVLXException",
"(",
"\"AliasArray::invalid_type_if_raw\"",
",",
"type_raw",
"=",
"type",
"(",
"raw",
")",
")",
"if",
"len",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | decode | Decode SLIP message. | pyvlx/slip.py | def decode(raw):
"""Decode SLIP message."""
return raw \
.replace(bytes([SLIP_ESC, SLIP_ESC_END]), bytes([SLIP_END])) \
.replace(bytes([SLIP_ESC, SLIP_ESC_ESC]), bytes([SLIP_ESC])) | def decode(raw):
"""Decode SLIP message."""
return raw \
.replace(bytes([SLIP_ESC, SLIP_ESC_END]), bytes([SLIP_END])) \
.replace(bytes([SLIP_ESC, SLIP_ESC_ESC]), bytes([SLIP_ESC])) | [
"Decode",
"SLIP",
"message",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/slip.py#L16-L20 | [
"def",
"decode",
"(",
"raw",
")",
":",
"return",
"raw",
".",
"replace",
"(",
"bytes",
"(",
"[",
"SLIP_ESC",
",",
"SLIP_ESC_END",
"]",
")",
",",
"bytes",
"(",
"[",
"SLIP_END",
"]",
")",
")",
".",
"replace",
"(",
"bytes",
"(",
"[",
"SLIP_ESC",
",",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | encode | Encode SLIP message. | pyvlx/slip.py | def encode(raw):
"""Encode SLIP message."""
return raw \
.replace(bytes([SLIP_ESC]), bytes([SLIP_ESC, SLIP_ESC_ESC])) \
.replace(bytes([SLIP_END]), bytes([SLIP_ESC, SLIP_ESC_END])) | def encode(raw):
"""Encode SLIP message."""
return raw \
.replace(bytes([SLIP_ESC]), bytes([SLIP_ESC, SLIP_ESC_ESC])) \
.replace(bytes([SLIP_END]), bytes([SLIP_ESC, SLIP_ESC_END])) | [
"Encode",
"SLIP",
"message",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/slip.py#L23-L27 | [
"def",
"encode",
"(",
"raw",
")",
":",
"return",
"raw",
".",
"replace",
"(",
"bytes",
"(",
"[",
"SLIP_ESC",
"]",
")",
",",
"bytes",
"(",
"[",
"SLIP_ESC",
",",
"SLIP_ESC_ESC",
"]",
")",
")",
".",
"replace",
"(",
"bytes",
"(",
"[",
"SLIP_END",
"]",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | get_next_slip | Get the next slip packet from raw data.
Returns the extracted packet plus the raw data with the remaining data stream. | pyvlx/slip.py | def get_next_slip(raw):
"""
Get the next slip packet from raw data.
Returns the extracted packet plus the raw data with the remaining data stream.
"""
if not is_slip(raw):
return None, raw
length = raw[1:].index(SLIP_END)
slip_packet = decode(raw[1:length+1])
new_raw = raw[lengt... | def get_next_slip(raw):
"""
Get the next slip packet from raw data.
Returns the extracted packet plus the raw data with the remaining data stream.
"""
if not is_slip(raw):
return None, raw
length = raw[1:].index(SLIP_END)
slip_packet = decode(raw[1:length+1])
new_raw = raw[lengt... | [
"Get",
"the",
"next",
"slip",
"packet",
"from",
"raw",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/slip.py#L30-L41 | [
"def",
"get_next_slip",
"(",
"raw",
")",
":",
"if",
"not",
"is_slip",
"(",
"raw",
")",
":",
"return",
"None",
",",
"raw",
"length",
"=",
"raw",
"[",
"1",
":",
"]",
".",
"index",
"(",
"SLIP_END",
")",
"slip_packet",
"=",
"decode",
"(",
"raw",
"[",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | set_utc | Enable house status monitor. | pyvlx/set_utc.py | async def set_utc(pyvlx):
"""Enable house status monitor."""
setutc = SetUTC(pyvlx=pyvlx)
await setutc.do_api_call()
if not setutc.success:
raise PyVLXException("Unable to set utc.") | async def set_utc(pyvlx):
"""Enable house status monitor."""
setutc = SetUTC(pyvlx=pyvlx)
await setutc.do_api_call()
if not setutc.success:
raise PyVLXException("Unable to set utc.") | [
"Enable",
"house",
"status",
"monitor",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/set_utc.py#L30-L35 | [
"async",
"def",
"set_utc",
"(",
"pyvlx",
")",
":",
"setutc",
"=",
"SetUTC",
"(",
"pyvlx",
"=",
"pyvlx",
")",
"await",
"setutc",
".",
"do_api_call",
"(",
")",
"if",
"not",
"setutc",
".",
"success",
":",
"raise",
"PyVLXException",
"(",
"\"Unable to set utc.\... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | SetUTC.handle_frame | Handle incoming API frame, return True if this was the expected frame. | pyvlx/set_utc.py | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameSetUTCConfirmation):
return False
self.success = True
return True | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameSetUTCConfirmation):
return False
self.success = True
return True | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/set_utc.py#L17-L22 | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameSetUTCConfirmation",
")",
":",
"return",
"False",
"self",
".",
"success",
"=",
"True",
"return",
"True"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | _slow_calcbinflux | Python implementation of ``calcbinflux``.
This is only used if ``synphot.synphot_utils`` C-extension
import fails.
See docstrings.py | synphot/binning.py | def _slow_calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw):
"""Python implementation of ``calcbinflux``.
This is only used if ``synphot.synphot_utils`` C-extension
import fails.
See docstrings.py
"""
binflux = np.empty(shape=(len_binwave, ), dtype=np.float64)
intwave = np.empty(shap... | def _slow_calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw):
"""Python implementation of ``calcbinflux``.
This is only used if ``synphot.synphot_utils`` C-extension
import fails.
See docstrings.py
"""
binflux = np.empty(shape=(len_binwave, ), dtype=np.float64)
intwave = np.empty(shap... | [
"Python",
"implementation",
"of",
"calcbinflux",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L17-L38 | [
"def",
"_slow_calcbinflux",
"(",
"len_binwave",
",",
"i_beg",
",",
"i_end",
",",
"avflux",
",",
"deltaw",
")",
":",
"binflux",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"(",
"len_binwave",
",",
")",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"in... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | calculate_bin_edges | Calculate the edges of wavelength bins given the centers.
The algorithm calculates bin edges as the midpoints between bin centers
and treats the first and last bins as symmetric about their centers.
Parameters
----------
centers : array-like or `~astropy.units.quantity.Quantity`
Sequence o... | synphot/binning.py | def calculate_bin_edges(centers):
"""Calculate the edges of wavelength bins given the centers.
The algorithm calculates bin edges as the midpoints between bin centers
and treats the first and last bins as symmetric about their centers.
Parameters
----------
centers : array-like or `~astropy.un... | def calculate_bin_edges(centers):
"""Calculate the edges of wavelength bins given the centers.
The algorithm calculates bin edges as the midpoints between bin centers
and treats the first and last bins as symmetric about their centers.
Parameters
----------
centers : array-like or `~astropy.un... | [
"Calculate",
"the",
"edges",
"of",
"wavelength",
"bins",
"given",
"the",
"centers",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L51-L92 | [
"def",
"calculate_bin_edges",
"(",
"centers",
")",
":",
"if",
"not",
"isinstance",
"(",
"centers",
",",
"u",
".",
"Quantity",
")",
":",
"centers",
"=",
"centers",
"*",
"u",
".",
"AA",
"if",
"centers",
".",
"ndim",
"!=",
"1",
":",
"raise",
"exceptions",... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | calculate_bin_widths | Calculate the widths of wavelengths bins given their edges.
Parameters
----------
edges : array-like or `~astropy.units.quantity.Quantity`
Sequence of bin edges. Must be 1D and have at least two values.
If not a Quantity, assumed to be in Angstrom.
Returns
-------
widths : `~as... | synphot/binning.py | def calculate_bin_widths(edges):
"""Calculate the widths of wavelengths bins given their edges.
Parameters
----------
edges : array-like or `~astropy.units.quantity.Quantity`
Sequence of bin edges. Must be 1D and have at least two values.
If not a Quantity, assumed to be in Angstrom.
... | def calculate_bin_widths(edges):
"""Calculate the widths of wavelengths bins given their edges.
Parameters
----------
edges : array-like or `~astropy.units.quantity.Quantity`
Sequence of bin edges. Must be 1D and have at least two values.
If not a Quantity, assumed to be in Angstrom.
... | [
"Calculate",
"the",
"widths",
"of",
"wavelengths",
"bins",
"given",
"their",
"edges",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L95-L126 | [
"def",
"calculate_bin_widths",
"(",
"edges",
")",
":",
"if",
"not",
"isinstance",
"(",
"edges",
",",
"u",
".",
"Quantity",
")",
":",
"edges",
"=",
"edges",
"*",
"u",
".",
"AA",
"if",
"edges",
".",
"ndim",
"!=",
"1",
":",
"raise",
"exceptions",
".",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | calculate_bin_centers | Calculate the centers of wavelengths bins given their edges.
Parameters
----------
edges : array-like or `~astropy.units.quantity.Quantity`
Sequence of bin edges. Must be 1D and have at least two values.
If not a Quantity, assumed to be in Angstrom.
Returns
-------
centers : `~... | synphot/binning.py | def calculate_bin_centers(edges):
"""Calculate the centers of wavelengths bins given their edges.
Parameters
----------
edges : array-like or `~astropy.units.quantity.Quantity`
Sequence of bin edges. Must be 1D and have at least two values.
If not a Quantity, assumed to be in Angstrom.
... | def calculate_bin_centers(edges):
"""Calculate the centers of wavelengths bins given their edges.
Parameters
----------
edges : array-like or `~astropy.units.quantity.Quantity`
Sequence of bin edges. Must be 1D and have at least two values.
If not a Quantity, assumed to be in Angstrom.
... | [
"Calculate",
"the",
"centers",
"of",
"wavelengths",
"bins",
"given",
"their",
"edges",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L129-L166 | [
"def",
"calculate_bin_centers",
"(",
"edges",
")",
":",
"if",
"not",
"isinstance",
"(",
"edges",
",",
"u",
".",
"Quantity",
")",
":",
"edges",
"=",
"edges",
"*",
"u",
".",
"AA",
"if",
"edges",
".",
"ndim",
"!=",
"1",
":",
"raise",
"exceptions",
".",
... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | wave_range | Calculate the wavelength range covered by the given number of pixels
centered on the given central wavelength of the given bins.
Parameters
----------
bins : array-like
Wavelengths at bin centers, each centered on a pixel.
Must be 1D array.
cenwave : float
Desired central w... | synphot/binning.py | def wave_range(bins, cenwave, npix, mode='round'):
"""Calculate the wavelength range covered by the given number of pixels
centered on the given central wavelength of the given bins.
Parameters
----------
bins : array-like
Wavelengths at bin centers, each centered on a pixel.
Must b... | def wave_range(bins, cenwave, npix, mode='round'):
"""Calculate the wavelength range covered by the given number of pixels
centered on the given central wavelength of the given bins.
Parameters
----------
bins : array-like
Wavelengths at bin centers, each centered on a pixel.
Must b... | [
"Calculate",
"the",
"wavelength",
"range",
"covered",
"by",
"the",
"given",
"number",
"of",
"pixels",
"centered",
"on",
"the",
"given",
"central",
"wavelength",
"of",
"the",
"given",
"bins",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L169-L358 | [
"def",
"wave_range",
"(",
"bins",
",",
"cenwave",
",",
"npix",
",",
"mode",
"=",
"'round'",
")",
":",
"mode",
"=",
"mode",
".",
"lower",
"(",
")",
"if",
"mode",
"not",
"in",
"(",
"'round'",
",",
"'min'",
",",
"'max'",
",",
"'none'",
")",
":",
"ra... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | pixel_range | Calculate the number of pixels within the given wavelength range
and the given bins.
Parameters
----------
bins : array-like
Wavelengths at bin centers, each centered on a pixel.
Must be 1D array.
waverange : tuple of float
Lower and upper limits of the desired wavelength r... | synphot/binning.py | def pixel_range(bins, waverange, mode='round'):
"""Calculate the number of pixels within the given wavelength range
and the given bins.
Parameters
----------
bins : array-like
Wavelengths at bin centers, each centered on a pixel.
Must be 1D array.
waverange : tuple of float
... | def pixel_range(bins, waverange, mode='round'):
"""Calculate the number of pixels within the given wavelength range
and the given bins.
Parameters
----------
bins : array-like
Wavelengths at bin centers, each centered on a pixel.
Must be 1D array.
waverange : tuple of float
... | [
"Calculate",
"the",
"number",
"of",
"pixels",
"within",
"the",
"given",
"wavelength",
"range",
"and",
"the",
"given",
"bins",
"."
] | spacetelescope/synphot_refactor | python | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L361-L486 | [
"def",
"pixel_range",
"(",
"bins",
",",
"waverange",
",",
"mode",
"=",
"'round'",
")",
":",
"mode",
"=",
"mode",
".",
"lower",
"(",
")",
"if",
"mode",
"not",
"in",
"(",
"'round'",
",",
"'min'",
",",
"'max'",
",",
"'none'",
")",
":",
"raise",
"excep... | 9c064f3cff0c41dd8acadc0f67c6350931275b9f |
train | PyVLX.connect | Connect to KLF 200. | pyvlx/pyvlx.py | async def connect(self):
"""Connect to KLF 200."""
PYVLXLOG.warning("Connecting to KLF 200.")
await self.connection.connect()
login = Login(pyvlx=self, password=self.config.password)
await login.do_api_call()
if not login.success:
raise PyVLXException("Login t... | async def connect(self):
"""Connect to KLF 200."""
PYVLXLOG.warning("Connecting to KLF 200.")
await self.connection.connect()
login = Login(pyvlx=self, password=self.config.password)
await login.do_api_call()
if not login.success:
raise PyVLXException("Login t... | [
"Connect",
"to",
"KLF",
"200",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/pyvlx.py#L42-L49 | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"PYVLXLOG",
".",
"warning",
"(",
"\"Connecting to KLF 200.\"",
")",
"await",
"self",
".",
"connection",
".",
"connect",
"(",
")",
"login",
"=",
"Login",
"(",
"pyvlx",
"=",
"self",
",",
"password",
"=",
"s... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | PyVLX.update_version | Retrieve version and protocol version from API. | pyvlx/pyvlx.py | async def update_version(self):
"""Retrieve version and protocol version from API."""
get_version = GetVersion(pyvlx=self)
await get_version.do_api_call()
if not get_version.success:
raise PyVLXException("Unable to retrieve version")
self.version = get_version.version... | async def update_version(self):
"""Retrieve version and protocol version from API."""
get_version = GetVersion(pyvlx=self)
await get_version.do_api_call()
if not get_version.success:
raise PyVLXException("Unable to retrieve version")
self.version = get_version.version... | [
"Retrieve",
"version",
"and",
"protocol",
"version",
"from",
"API",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/pyvlx.py#L51-L65 | [
"async",
"def",
"update_version",
"(",
"self",
")",
":",
"get_version",
"=",
"GetVersion",
"(",
"pyvlx",
"=",
"self",
")",
"await",
"get_version",
".",
"do_api_call",
"(",
")",
"if",
"not",
"get_version",
".",
"success",
":",
"raise",
"PyVLXException",
"(",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | PyVLX.send_frame | Send frame to API via connection. | pyvlx/pyvlx.py | async def send_frame(self, frame):
"""Send frame to API via connection."""
if not self.connection.connected:
await self.connect()
await self.update_version()
await set_utc(pyvlx=self)
await house_status_monitor_enable(pyvlx=self)
self.connection.wr... | async def send_frame(self, frame):
"""Send frame to API via connection."""
if not self.connection.connected:
await self.connect()
await self.update_version()
await set_utc(pyvlx=self)
await house_status_monitor_enable(pyvlx=self)
self.connection.wr... | [
"Send",
"frame",
"to",
"API",
"via",
"connection",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/pyvlx.py#L67-L74 | [
"async",
"def",
"send_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"self",
".",
"connection",
".",
"connected",
":",
"await",
"self",
".",
"connect",
"(",
")",
"await",
"self",
".",
"update_version",
"(",
")",
"await",
"set_utc",
"(",
"pyv... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Scene.from_config | Read scene from configuration. | old_api/pyvlx/scene.py | def from_config(cls, pyvlx, item):
"""Read scene from configuration."""
name = item['name']
ident = item['id']
return cls(pyvlx, ident, name) | def from_config(cls, pyvlx, item):
"""Read scene from configuration."""
name = item['name']
ident = item['id']
return cls(pyvlx, ident, name) | [
"Read",
"scene",
"from",
"configuration",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scene.py#L14-L18 | [
"def",
"from_config",
"(",
"cls",
",",
"pyvlx",
",",
"item",
")",
":",
"name",
"=",
"item",
"[",
"'name'",
"]",
"ident",
"=",
"item",
"[",
"'id'",
"]",
"return",
"cls",
"(",
"pyvlx",
",",
"ident",
",",
"name",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Interface.api_call | Send api call. | old_api/pyvlx/interface.py | async def api_call(self, verb, action, params=None, add_authorization_token=True, retry=False):
"""Send api call."""
if add_authorization_token and not self.token:
await self.refresh_token()
try:
return await self._api_call_impl(verb, action, params, add_authorization_to... | async def api_call(self, verb, action, params=None, add_authorization_token=True, retry=False):
"""Send api call."""
if add_authorization_token and not self.token:
await self.refresh_token()
try:
return await self._api_call_impl(verb, action, params, add_authorization_to... | [
"Send",
"api",
"call",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L19-L31 | [
"async",
"def",
"api_call",
"(",
"self",
",",
"verb",
",",
"action",
",",
"params",
"=",
"None",
",",
"add_authorization_token",
"=",
"True",
",",
"retry",
"=",
"False",
")",
":",
"if",
"add_authorization_token",
"and",
"not",
"self",
".",
"token",
":",
... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Interface.refresh_token | Refresh API token from KLF 200. | old_api/pyvlx/interface.py | async def refresh_token(self):
"""Refresh API token from KLF 200."""
json_response = await self.api_call('auth', 'login', {'password': self.config.password}, add_authorization_token=False)
if 'token' not in json_response:
raise PyVLXException('no element token found in response: {0}'... | async def refresh_token(self):
"""Refresh API token from KLF 200."""
json_response = await self.api_call('auth', 'login', {'password': self.config.password}, add_authorization_token=False)
if 'token' not in json_response:
raise PyVLXException('no element token found in response: {0}'... | [
"Refresh",
"API",
"token",
"from",
"KLF",
"200",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L62-L67 | [
"async",
"def",
"refresh_token",
"(",
"self",
")",
":",
"json_response",
"=",
"await",
"self",
".",
"api_call",
"(",
"'auth'",
",",
"'login'",
",",
"{",
"'password'",
":",
"self",
".",
"config",
".",
"password",
"}",
",",
"add_authorization_token",
"=",
"F... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Interface.create_body | Create http body for rest request. | old_api/pyvlx/interface.py | def create_body(action, params):
"""Create http body for rest request."""
body = {}
body['action'] = action
if params is not None:
body['params'] = params
return body | def create_body(action, params):
"""Create http body for rest request."""
body = {}
body['action'] = action
if params is not None:
body['params'] = params
return body | [
"Create",
"http",
"body",
"for",
"rest",
"request",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L89-L95 | [
"def",
"create_body",
"(",
"action",
",",
"params",
")",
":",
"body",
"=",
"{",
"}",
"body",
"[",
"'action'",
"]",
"=",
"action",
"if",
"params",
"is",
"not",
"None",
":",
"body",
"[",
"'params'",
"]",
"=",
"params",
"return",
"body"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Interface.evaluate_response | Evaluate rest response. | old_api/pyvlx/interface.py | def evaluate_response(json_response):
"""Evaluate rest response."""
if 'errors' in json_response and json_response['errors']:
Interface.evaluate_errors(json_response)
elif 'result' not in json_response:
raise PyVLXException('no element result found in response: {0}'.form... | def evaluate_response(json_response):
"""Evaluate rest response."""
if 'errors' in json_response and json_response['errors']:
Interface.evaluate_errors(json_response)
elif 'result' not in json_response:
raise PyVLXException('no element result found in response: {0}'.form... | [
"Evaluate",
"rest",
"response",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L98-L105 | [
"def",
"evaluate_response",
"(",
"json_response",
")",
":",
"if",
"'errors'",
"in",
"json_response",
"and",
"json_response",
"[",
"'errors'",
"]",
":",
"Interface",
".",
"evaluate_errors",
"(",
"json_response",
")",
"elif",
"'result'",
"not",
"in",
"json_response"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | Interface.evaluate_errors | Evaluate rest errors. | old_api/pyvlx/interface.py | def evaluate_errors(json_response):
"""Evaluate rest errors."""
if 'errors' not in json_response or \
not isinstance(json_response['errors'], list) or \
not json_response['errors'] or \
not isinstance(json_response['errors'][0], int):
raise PyVLXException('Co... | def evaluate_errors(json_response):
"""Evaluate rest errors."""
if 'errors' not in json_response or \
not isinstance(json_response['errors'], list) or \
not json_response['errors'] or \
not isinstance(json_response['errors'][0], int):
raise PyVLXException('Co... | [
"Evaluate",
"rest",
"errors",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L108-L122 | [
"def",
"evaluate_errors",
"(",
"json_response",
")",
":",
"if",
"'errors'",
"not",
"in",
"json_response",
"or",
"not",
"isinstance",
"(",
"json_response",
"[",
"'errors'",
"]",
",",
"list",
")",
"or",
"not",
"json_response",
"[",
"'errors'",
"]",
"or",
"not"... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameSetNodeNameRequest.get_payload | Return Payload. | pyvlx/frames/frame_set_node_name.py | def get_payload(self):
"""Return Payload."""
ret = bytes([self.node_id])
ret += string_to_bytes(self.name, 64)
return ret | def get_payload(self):
"""Return Payload."""
ret = bytes([self.node_id])
ret += string_to_bytes(self.name, 64)
return ret | [
"Return",
"Payload",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_set_node_name.py#L21-L25 | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"bytes",
"(",
"[",
"self",
".",
"node_id",
"]",
")",
"ret",
"+=",
"string_to_bytes",
"(",
"self",
".",
"name",
",",
"64",
")",
"return",
"ret"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameSetNodeNameRequest.from_payload | Init frame from binary data. | pyvlx/frames/frame_set_node_name.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.name = bytes_to_string(payload[1:65]) | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.name = bytes_to_string(payload[1:65]) | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_set_node_name.py#L27-L30 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"node_id",
"=",
"payload",
"[",
"0",
"]",
"self",
".",
"name",
"=",
"bytes_to_string",
"(",
"payload",
"[",
"1",
":",
"65",
"]",
")"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | FrameSetNodeNameConfirmation.from_payload | Init frame from binary data. | pyvlx/frames/frame_set_node_name.py | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = SetNodeNameConfirmationStatus(payload[0])
self.node_id = payload[1] | def from_payload(self, payload):
"""Init frame from binary data."""
self.status = SetNodeNameConfirmationStatus(payload[0])
self.node_id = payload[1] | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_set_node_name.py#L60-L63 | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"status",
"=",
"SetNodeNameConfirmationStatus",
"(",
"payload",
"[",
"0",
"]",
")",
"self",
".",
"node_id",
"=",
"payload",
"[",
"1",
"]"
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
train | convert_frame_to_node | Convert FrameGet[All]Node[s]InformationNotification into Node object. | pyvlx/node_helper.py | def convert_frame_to_node(pyvlx, frame):
"""Convert FrameGet[All]Node[s]InformationNotification into Node object."""
# pylint: disable=too-many-return-statements
if frame.node_type == NodeTypeWithSubtype.WINDOW_OPENER:
return Window(pyvlx=pyvlx, node_id=frame.node_id, name=frame.name, rain_sensor=Fa... | def convert_frame_to_node(pyvlx, frame):
"""Convert FrameGet[All]Node[s]InformationNotification into Node object."""
# pylint: disable=too-many-return-statements
if frame.node_type == NodeTypeWithSubtype.WINDOW_OPENER:
return Window(pyvlx=pyvlx, node_id=frame.node_id, name=frame.name, rain_sensor=Fa... | [
"Convert",
"FrameGet",
"[",
"All",
"]",
"Node",
"[",
"s",
"]",
"InformationNotification",
"into",
"Node",
"object",
"."
] | Julius2342/pyvlx | python | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/node_helper.py#L8-L30 | [
"def",
"convert_frame_to_node",
"(",
"pyvlx",
",",
"frame",
")",
":",
"# pylint: disable=too-many-return-statements",
"if",
"frame",
".",
"node_type",
"==",
"NodeTypeWithSubtype",
".",
"WINDOW_OPENER",
":",
"return",
"Window",
"(",
"pyvlx",
"=",
"pyvlx",
",",
"node_... | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.