code stringlengths 1 18.2k |
|---|
``binned``. flux_unit : str or `~astropy.units.core.Unit` or `None` Flux is converted to this unit for plotting. If not given, internal unit is used. area, vegaspec See :func:`~synphot.units.convert_flux`. kwargs : dict See :func:`synphot.spectrum.BaseSpectrum.plot`. Raises ------ synphot.exceptions.SynphotError Invali... |
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 manipulate and takes up less memo... |
file. Parameters ---------- binned : bool Write out data in native wavelengths if `False`. Else, write binned data (default). 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.waveset`` or `binset` is u... |
self._internal_flux_unit) else: w, y = self._get_arrays( wavelengths, flux_unit=self._internal_flux_unit) header = {'observation': str(self), 'binned': binned} return SourceSpectrum(Empirical1D, points=w, lookup_table=y, meta={'header': header}) |
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 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.stop_timeout() self.pyvlx.connection.unregister_frame_recei... |
async def start_timeout(self): """Start timeout.""" self.timeout_handle = self.pyvlx.connection.loop.call_later( self.timeout_in_seconds, self.timeout) |
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_scenes() print(pyvlx.scenes[0]) print(... |
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") self.parameter = parameter await self.after_update... |
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 multiply the SEDs by this fa... |
al. (1995) <synphot-ref-madau1995>`. This is claimed accurate to 5%. The scatter in this factor (due to different lines of sight) is huge, as shown in Madau's Fig. 3 (top panel); The figure's bottom panel shows a redshifted version of the "exact" prescription. Parameters ---------- wave : array-like or `~astropy.units.... |
kwargs : dict Equivalencies for unit conversion, see :func:`~synphot.units.validate_quantity`. Returns ------- extcurve : `ExtinctionCurve` Extinction curve to apply to the redshifted spectrum. """ if not isinstance(z, numbers.Real): raise exceptions.SynphotError( 'Redshift must be a real scalar number.') if np.isscala... |
= np.array([1216, 1026, 973, 950], dtype=np.float) # noqa tau = np.zeros_like(wave, dtype=np.float) xe = 1.0 + z # Lyman series for i in range(len(el)): tau = np.where(wave <= el[i] * xe, tau + c[i] * (wave / el[i]) ** 3.46, tau) # Photoelectric absorption xc = wave / ll xc3 = xc ** 3 tau = np.where(wave <= ll * xe, (t... |
* xc3 * (xe ** 0.46 - xc ** 0.46) + 9.4 * xc ** 1.5 * (xe ** 0.18 - xc ** 0.18) - 0.7 * xc3 * (xc ** (-1.32) - xe ** (-1.32)) - 0.023 * (xe ** 1.68 - xc ** 1.68)), tau) thru = np.where(tau > 700., 0., np.exp(-tau)) meta = {'descrip': 'Madau 1995 extinction for z={0}'.format(z)} return ExtinctionCurve(ExtinctionModel1D, |
points=wave, lookup_table=thru, meta=meta) |
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)` value in magnitude. wavelengths : array-like, `~astropy.units.quantity.Quantity`,... |
Raises ------ synphot.exceptions.SynphotError Invalid input. """ if isinstance(ebv, u.Quantity) and ebv.unit.decompose() == u.mag: ebv = ebv.value elif not isinstance(ebv, numbers.Real): raise exceptions.SynphotError('E(B-V)={0} is invalid.'.format(ebv)) x = self._validate_wavelengths(wavelengths).value y = 10 ** (-0.4... |
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.quantity.Quantity`, or `None` Wavelength values for sampling. If not... |
'Av/E(B-V)' kwargs['flux_unit'] = self._internal_flux_unit # No need to trim/pad zeroes, unless user chooses to do so. if 'pad_zero_ends' not in kwargs: kwargs['pad_zero_ends'] = False if 'trim_zero' not in kwargs: kwargs['trim_zero'] = False # There are some standard keywords that should be added # to the extension he... |
in kwargs: kwargs['ext_header'].update(bkeys) else: kwargs['ext_header'] = bkeys specio.write_fits_spec(filename, w, y, **kwargs) |
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 Keywords acceptable by :func:`~synphot.specio.read_fits_spec` (if FITS) or :... |
= cls._internal_flux_unit if ((filename.endswith('fits') or filename.endswith('fit')) and 'flux_col' not in kwargs): kwargs['flux_col'] = 'Av/E(B-V)' header, wavelengths, rvs = specio.read_spec(filename, **kwargs) return cls(Empirical1D, points=wavelengths, lookup_table=rvs, meta={'header': header}) |
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', or 'xgalsb'. kwargs : dict Keywords acceptable by :func:`... |
'lmc30dor': cfgitem = Conf.lmc30dor_file elif modelname == 'lmcavg': cfgitem = Conf.lmcavg_file elif modelname == 'mwavg': cfgitem = Conf.mwavg_file elif modelname == 'mwdense': cfgitem = Conf.mwdense_file elif modelname == 'mwrv21': cfgitem = Conf.mwrv21_file elif modelname == 'mwrv40': cfgitem = Conf.mwrv40_file elif... |
if 'flux_unit' not in kwargs: kwargs['flux_unit'] = cls._internal_flux_unit if ((filename.endswith('fits') or filename.endswith('fit')) and 'flux_col' not in kwargs): kwargs['flux_col'] = 'Av/E(B-V)' header, wavelengths, rvs = specio.read_remote_spec(filename, **kwargs) header['filename'] = filename header['descrip'] =... |
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 |
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 PyVLXException("Invalid payload len", expected_len=self.PAYLOAD_LEN, c... |
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 ret |
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_completion=wait_for_completion, scene_id=self.scene_id) await activate_scene.do_api_call()... |
def add(self, scene): """Add scene.""" if not isinstance(scene, Scene): raise TypeError() self.__scenes.append(scene) |
async def load(self): """Load scenes from KLF 200.""" json_response = await self.pyvlx.interface.api_call('scenes', 'get') self.data_import(json_response) |
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.load_scene(item) |
def load_scene(self, item): """Load scene from json.""" scene = Scene.from_config(self.pyvlx, item) self.add(scene) |
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 = frame.gateway_sub_state return True |
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_alias = raw[0] if nbr_of_alias > 5: raise PyVLXException(... |
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 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 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[length+2:] return slip_packet, new_raw |
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 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 |
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(shape=(len_binwave, ), dtype=np.flo... |
binflux[i] = np.sum(avflux[first:last] * cur_dw) / intwave[i] return binflux, intwave |
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.units.quantity.Quantity` Seq... |
------- edges : `~astropy.units.quantity.Quantity` Array of bin edges. Will be 1D, have one more value than ``centers``, and also the same unit. Raises ------ synphot.exceptions.SynphotError Invalid input. """ if not isinstance(centers, u.Quantity): centers = centers * u.AA if centers.ndim != 1: raise exceptions.Synpho... |
np.empty(centers.size + 1, dtype=np.float64) edges[1:-1] = (centers.value[1:] + centers.value[:-1]) * 0.5 # Compute the first and last by making them symmetric edges[0] = 2.0 * centers.value[0] - edges[1] edges[-1] = 2.0 * centers.value[-1] - edges[-2] return edges * centers.unit |
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. Returns ------- widths : `~astropy.... |
------ synphot.exceptions.SynphotError Invalid input. """ if not isinstance(edges, u.Quantity): edges = edges * u.AA if edges.ndim != 1: raise exceptions.SynphotError('Bin edges must be 1D array.') if edges.size < 2: raise exceptions.SynphotError( 'Bin edges must have at least two values.') return np.abs(edges[1:] - ed... |
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. Returns ------- centers : `~astro... |
------ synphot.exceptions.SynphotError Invalid input. """ if not isinstance(edges, u.Quantity): edges = edges * u.AA if edges.ndim != 1: raise exceptions.SynphotError('Bin edges must be 1D array.') if edges.size < 2: raise exceptions.SynphotError( 'Bin edges must have at least two values.') centers = np.empty(edges.siz... |
* edges.unit |
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 be 1D array. cenwave : float Desired c... |
on ``cenwave``. mode : {'round', 'min', 'max', 'none'} Determines how the pixels at the edges of the wavelength range are handled. All the options, except 'none', will return wavelength range edges that correspond to pixel edges: * 'round' - Wavelength range edges are the pixel edges and the range spans exactly ``npix`... |
rounded to the nearest pixel edge. This is the default. * 'min' - Wavelength range is shrunk such that it includes an integer number of pixels and its edges fall on pixel edges. It may not span exactly ``npix`` pixels. * 'max' - Wavelength range is expanded such that it includes an integer number of pixels and its edge... |
may not span exactly ``npix`` pixels. * 'none' - Exact wavelength range is returned. The edges may not correspond to pixel edges, but it covers exactly ``npix`` pixels. Returns ------- wave1, wave2 : float Lower and upper limits of the wavelength range. Raises ------ synphot.exceptions.OverlapError Given central wavele... |
Invalid inputs or calculation failed. """ mode = mode.lower() if mode not in ('round', 'min', 'max', 'none'): raise exceptions.SynphotError( 'mode={0} is invalid, must be "round", "min", "max", ' 'or "none".'.format(mode)) if not isinstance(npix, int): raise exceptions.SynphotError('npix={0} is invalid.'.format(npix)) ... |
bins[0] or cenwave > bins[-1]: raise exceptions.OverlapError( 'cenwave={0} is not within binset (min={1}, max={2}).'.format( cenwave, bins[0], bins[-1])) # Find the index the central wavelength among bins diff = cenwave - bins ind = np.argmin(np.abs(diff)) # Calculate fractional index frac_ind = float(ind) if diff[ind]... |
1] - bins[ind]) # Calculate fractional indices of the edges half_npix = npix / 2.0 frac_ind1 = frac_ind - half_npix frac_ind2 = frac_ind + half_npix # Calculated edges must not exceed bin edges if frac_ind1 < -0.5: raise exceptions.OverlapError( 'Lower limit of wavelength range is out of bounds.') if frac_ind2 > (bins.... |
bounds.') frac1, int1 = np.modf(frac_ind1) frac2, int2 = np.modf(frac_ind2) int1 = int(int1) int2 = int(int2) if mode == 'round': # Lower end of wavelength range if frac1 >= 0: # end is somewhere greater than binset[0] so we can just # interpolate between two neighboring values going with upper edge wave1 = bins[int1:i... |
but not by enough to # trigger an exception wave1 = bins[0] - (bins[0:2].mean() - bins[0]) # Upper end of wavelength range if int2 < bins.shape[0] - 1: # end is somewhere below binset[-1] so we can just interpolate # between two neighboring values, going with the upper edge. wave2 = bins[int2:int2 + 2].mean() else: # e... |
by enough to # trigger an exception wave2 = bins[-1] + (bins[-1] - bins[-2:].mean()) elif mode == 'min': # Lower end of wavelength range if frac1 <= 0.5 and int1 < bins.shape[0] - 1: # not at the lowest possible edge and pixel i included wave1 = bins[int1:int1 + 2].mean() elif frac1 > 0.5 and int1 < bins.shape[0] - 2: ... |
lowest possible edge and pixel i not included wave1 = bins[int1 + 1:int1 + 3].mean() elif frac1 == -0.5: # at the lowest possible edge wave1 = bins[0] - (bins[0:2].mean() - bins[0]) else: # pragma: no cover raise exceptions.SynphotError( 'mode={0} gets unexpected frac1={1}, int1={2}'.format( mode, frac1, int1)) # Upper... |
not out at the end and pixel i included wave2 = bins[int2:int2 + 2].mean() elif frac2 < 0.5 and int2 < bins.shape[0]: # not out at end and pixel i not included wave2 = bins[int2 - 1:int2 + 1].mean() elif frac2 == 0.5 and int2 == bins.shape[0] - 1: # at the very end wave2 = bins[-1] + (bins[-1] - bins[-2:].mean()) else:... |
no cover raise exceptions.SynphotError( 'mode={0} gets unexpected frac2={1}, int2={2}'.format( mode, frac2, int2)) elif mode == 'max': # Lower end of wavelength range if frac1 < 0.5 and int1 < bins.shape[0]: # not at the lowest possible edge and pixel i included wave1 = bins[int1 - 1:int1 + 1].mean() elif frac1 >= 0.5 ... |
edge and pixel i not included wave1 = bins[int1:int1 + 2].mean() elif frac1 == -0.5: # at the lowest possible edge wave1 = bins[0] - (bins[0:2].mean() - bins[0]) else: # pragma: no cover raise exceptions.SynphotError( 'mode={0} gets unexpected frac1={1}, int1={2}'.format( mode, frac1, int1)) # Upper end of wavelength r... |
end and pixel i included wave2 = bins[int2 + 1:int2 + 3].mean() elif frac2 <= 0.5 and int2 < bins.shape[0] - 1: # not out at end and pixel i not included wave2 = bins[int2:int2 + 2].mean() elif frac2 == 0.5 and int2 == bins.shape[0] - 1: # at the very end wave2 = bins[-1] + (bins[-1] - bins[-2:].mean()) else: # pragma:... |
raise exceptions.SynphotError( 'mode={0} gets unexpected frac2={1}, int2={2}'.format( mode, frac2, int2)) else: # mode == 'none' wave1 = bins[int1] + frac1 * (bins[int1 + 1] - bins[int1]) wave2 = bins[int2] + frac2 * (bins[int2 + 1] - bins[int2]) return wave1, wave2 |
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 Lower and upper limits of the desired wavelen... |
the pixels at the edges of the wavelength range are handled. All the options, except 'none', will return an integer number of pixels: * 'round' - Wavelength range edges that fall in the middle of a pixel are counted if more than half of the pixel is within the given wavelength range. Edges that fall in the center of a ... |
the nearest pixel edge. This is the default. * 'min' - Only pixels wholly within the given wavelength range are counted. * 'max' - Pixels that are within the given wavelength range by any margin are counted. * 'none' - The exact number of encompassed pixels, including fractional pixels, is returned. Returns ------- npi... |
range exceeds the bounds of given bins. synphot.exceptions.SynphotError Invalid mode. """ mode = mode.lower() if mode not in ('round', 'min', 'max', 'none'): raise exceptions.SynphotError( 'mode={0} is invalid, must be "round", "min", "max", ' 'or "none".'.format(mode)) if waverange[0] < waverange[-1]: wave1 = waverang... |
bins = bins[::-1] # Wavelength range must be within bins minwave = bins[0] - (bins[0:2].mean() - bins[0]) maxwave = bins[-1] + (bins[-1] - bins[-2:].mean()) if wave1 < minwave or wave2 > maxwave: raise exceptions.OverlapError( 'Wavelength range ({0}, {1}) is out of bounds of bins ' '(min={2}, max={3}).'.format(wave1, w... |
ind2 = bins.searchsorted(wave2, side='right') else: ind1 = bins.searchsorted(wave1, side='left') ind2 = bins.searchsorted(wave2, side='left') if mode == 'round': npix = ind2 - ind1 elif mode == 'min': # for ind1, figure out if pixel ind1 is wholly included or not. # do this by figuring out where wave1 is between ind1 a... |
frac < 0.5: # ind1 is only partially included ind1 += 1 # similar but reversed procedure for ind2 frac = (wave2 - bins[ind2 - 1]) / (bins[ind2] - bins[ind2 - 1]) if frac < 0.5: # ind2 is only partially included ind2 -= 1 npix = ind2 - ind1 elif mode == 'max': # for ind1, figure out if pixel ind1-1 is partially |
included or not. # do this by figuring out where wave1 is between ind1 and ind1-1. frac = (wave1 - bins[ind1 - 1]) / (bins[ind1] - bins[ind1 - 1]) if frac < 0.5: # ind1 is partially included ind1 -= 1 # similar but reversed procedure for ind2 frac = (bins[ind2] - wave2) / (bins[ind2] - bins[ind2 - 1]) if frac < 0.5: # |
ind2 is partially included ind2 += 1 npix = ind2 - ind1 else: # mode == 'none' # calculate fractional indices frac1 = ind1 - (bins[ind1] - wave1) / (bins[ind1] - bins[ind1 - 1]) frac2 = ind2 - (bins[ind2] - wave2) / (bins[ind2] - bins[ind2 - 1]) npix = frac2 - frac1 return npix |
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 to KLF 200 failed, check credentials") |
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 get_protocol_version = GetProtocolVersion(pyvlx=sel... |
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.write(frame) |
def from_config(cls, pyvlx, item): """Read scene from configuration.""" name = item['name'] ident = item['id'] return cls(pyvlx, ident, name) |
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_token) except InvalidToken: if not retry and add_au... |
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}'.format(json.dumps(json_response))) ... |
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 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}'.format(json.dumps(json_response))) elif not json_resp... |
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('Could not evaluate errors {0}'.format(json.dumps(json_response)... |
def get_payload(self): """Return Payload.""" ret = bytes([self.node_id]) ret += string_to_bytes(self.name, 64) return ret |
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.status = SetNodeNameConfirmationStatus(payload[0]) self.node_id = payload[1] |
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=False) if frame.node_t... |
name=frame.name) if frame.node_type == NodeTypeWithSubtype.VERTICAL_EXTERIOR_AWNING or \ frame.node_type == NodeTypeWithSubtype.HORIZONTAL_AWNING: return Awning(pyvlx=pyvlx, node_id=frame.node_id, name=frame.name) if frame.node_type == NodeTypeWithSubtype.ON_OFF_SWITCH: return OnOffSwitch(pyvlx=pyvlx, node_id=frame.nod... |
def temperature(self, what): """Set temperature.""" self._temperature = units.validate_quantity(what, u.K) |
def thermal_source(self): """Apply emissivity to an existing beam to produce a thermal source spectrum (without optical counterpart). Thermal source spectrum is calculated as follow: #. Create a blackbody spectrum in PHOTLAM per square arcsec with `temperature`. #. Multiply the blackbody with `beam_fill_factor` and ``s... |
= self.temperature sp.meta['beam_fill_factor'] = self.beam_fill_factor return sp |
def from_file(cls, filename, temperature_key='DEFT', beamfill_key='BEAMFILL', **kwargs): """Creates a thermal spectral element from file. .. note:: Only FITS format is supported. Parameters ---------- filename : str Thermal spectral element filename. temperature_key, beamfill_key : str Keywords in FITS *table extension... |
acceptable by :func:`~synphot.specio.read_fits_spec`. Returns ------- th : `ThermalSpectralElement` Empirical thermal spectral element. Raises ------ synphot.exceptions.SynphotError Invalid inputs. """ if not (filename.endswith('fits') or filename.endswith('fit')): raise exceptions.SynphotError('Only FITS format is sup... |
kwargs['flux_unit'] = cls._internal_flux_unit if 'flux_col' not in kwargs: kwargs['flux_col'] = 'EMISSIVITY' header, wavelengths, em = specio.read_spec(filename, **kwargs) return cls( Empirical1D, temperature, beam_fill_factor=beam_fill_factor, points=wavelengths, lookup_table=em, meta={'header': header}) |
def from_payload(self, payload): """Init frame from binary data.""" self.status = AllNodesInformationStatus(payload[0]) self.number_of_nodes = payload[1] |
def get_payload(self): """Return Payload.""" payload = bytes() payload += bytes([self.node_id]) payload += bytes([self.order >> 8 & 255, self.order & 255]) payload += bytes([self.placement]) payload += bytes(string_to_bytes(self.name, 64)) payload += bytes([self.velocity.value]) payload += bytes([self.node_type.value >... |
payload += bytes(self.target.raw) payload += bytes(self.current_position_fp1.raw) payload += bytes(self.current_position_fp2.raw) payload += bytes(self.current_position_fp3.raw) payload += bytes(self.current_position_fp4.raw) payload += bytes([self.remaining_time >> 8 & 255, self.remaining_time & 255]) payload += struc... |
def from_payload(self, payload): """Init frame from binary data.""" self.node_id = payload[0] self.order = payload[1] * 256 + payload[2] self.placement = payload[3] self.name = bytes_to_string(payload[4:68]) self.velocity = Velocity(payload[68]) self.node_type = NodeTypeWithSubtype(payload[69] * 256 + payload[70]) self... |
self.current_position_fp2 = Parameter(payload[91:93]) self.current_position_fp3 = Parameter(payload[93:95]) self.current_position_fp4 = Parameter(payload[95:97]) self.remaining_time = payload[97] * 256 + payload[98] self.timestamp = struct.unpack(">I", payload[99:103])[0] self.alias_array = AliasArray(payload[103:125]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.