text
stringlengths
81
112k
Draw a grid of RA/DEC on Canvas. def coord_grid(self): """Draw a grid of RA/DEC on Canvas.""" import math,ephem ra2=math.pi*2 ra1=0 dec1=-1*math.pi/2.0 dec2=math.pi/2.0 ## grid space choices ## ra space in hours ra_grids=["06:00:00", ...
Write label at plot coordinates (x,y) def label(self,x,y,label,offset=[0,0]): """Write label at plot coordinates (x,y)""" (xc,yc)=self.p2c([x,y]) return self.create_text(xc-offset[0],yc-offset[1],text=label)
Set the coordinate boundaries of plot def limits(self,x1,x2,y1,y2): """Set the coordinate boundaries of plot""" import math self.x1=x1 self.x2=x2 self.y1=y1 self.y2=y2 self.xscale=(self.cx2-self.cx1)/(self.x2-self.x1) self.yscale=(self.cy2-self.cy1)/(self...
Expand to the full scale def reset(self): """Expand to the full scale""" import ephem, MOPcoord sun=ephem.Sun() sun.compute(self.date.get()) self.sun=MOPcoord.coord((sun.ra,sun.dec)) doplot(kbos) self.plot_pointings()
Put this object in the search box def updateObj(self,event): """Put this object in the search box""" name=w.objList.get("active") w.SearchVar.set(name) w.ObjInfo.set(objInfoDict[name]) return
Move to the postion of self.SearchVar def relocate(self): """Move to the postion of self.SearchVar""" name=self.SearchVar.get() if kbos.has_key(name): import orbfit,ephem,math jdate=ephem.julian_date(w.date.get()) try: (ra,dec,a,b,ang)=orbfit.predict(kbos[name],jdate,...
Zoom in def __zoom(self,event,scale=2.0): """Zoom in""" import Tkinter,math ## compute the x,y of the center of the screen sx1=self.cx1+(self.cx2-self.cx1+1.0)/2.0 sy1=self.cy1+(self.cy2-self.cy1+1.0)/2.0 #print sx1,sy1 if not event is None: sx1=event.x sy1=event.y #prin...
Plot ellipse at x,y with size a,b and orientation ang def create_ellipse(self,xcen,ycen,a,b,ang,resolution=40.0): """Plot ellipse at x,y with size a,b and orientation ang""" import math e1=[] e2=[] ang=ang-math.radians(90) for i in range(0,int(resolution)+1): ...
Query for some pointings, given a block name def get_pointings(self): """Query for some pointings, given a block name""" import MOPdbaccess,ephem,math import tkSimpleDialog result = tkSimpleDialog.askstring("Block Load", "Which Block do you want to plot?") db = MOPdbaccess.connect('buc...
Load some pointings def load_pointings(self): """Load some pointings""" import os,re,ephem import tkFileDialog,tkMessageBox filename=tkFileDialog.askopenfilename() if filename is None: return f=open(filename) lines=f.readlines() f.close() points=[] if lines[0][...
Plot the sky coverage of pointing at event.x,event.y on the canavas def create_pointing(self,event): """Plot the sky coverage of pointing at event.x,event.y on the canavas""" import math (ra,dec)=self.c2p((self.canvasx(event.x), self.canvasy(event.y))) this_c...
Plot pointings on canavs def plot_pointings(self,pointings=None): """Plot pointings on canavs""" if pointings is None: pointings=self.pointings i=0 for pointing in pointings: items=[] i=i+1 label={} label['text']=pointing['label']['text'] fo...
Let the label of the current pointing to the value in the plabel box def set_pointing_label(self): """Let the label of the current pointing to the value in the plabel box""" self.pointings[self.current]['label']['text']=w.plabel.get() self.reset()
Print the currently defined FOVs def save_pointings(self): """Print the currently defined FOVs""" import tkFileDialog f=tkFileDialog.asksaveasfile() i=0 if self.pointing_format.get()=='CFHT PH': f.write("""<?xml version = "1.0"?> <!DOCTYPE ASTRO SYSTEM "http://vizier.u-str...
Return an array of rectangles that represent the 'ra,dec' corners of the FOV def getGeometry(self,ra=None,dec=None): """Return an array of rectangles that represent the 'ra,dec' corners of the FOV""" import math,ephem ccds=[] if ra is None: ra=self.ra if dec is Non...
Compute the separation between self and (ra,dec) def separation(self,ra,dec): """Compute the separation between self and (ra,dec)""" import ephem return ephem.separation((self.ra,self.dec),(ra,dec))
Produce random, binary features, totally irrespective of the content of x, but in the same shape as x. def produce_fake_hash(x): """ Produce random, binary features, totally irrespective of the content of x, but in the same shape as x. """ h = np.random.binomial(1, 0.5, (x.shape[0], 1024)) ...
Convert a string of hexadecimal values to decimal values parameters Example: '0x2E 0xF1 0x80 0x28 0x00 0x1A 0x01 0x00' is converted to: 46, 241, [128, 40, 0, 26, 1, 0] :param raw_bytes: string of hexadecimal values :returns: 3 decimal values def _parse_raw_bytes(raw_bytes): """Convert a...
Use IPMI command object to send raw ipmi command to BMC :param ipmicmd: IPMI command object :param raw_bytes: string of hexadecimal values. This is commonly used for certain vendor specific commands. :returns: dict -- The response from IPMI device def _send_raw_command(ipmicmd, raw_bytes): """...
Get the TPM support status. Get the TPM support status of the node. :param d_info: the list of ipmitool parameters for accessing a node. :returns: TPM support status def get_tpm_status(d_info): """Get the TPM support status. Get the TPM support status of the node. :param d_info: the list of...
Get output of ipmiraw command and the ordinal numbers. :param ipmicmd: IPMI command object. :returns: List of tuple contain ordinal number and output of ipmiraw command. def _pci_seq(ipmicmd): """Get output of ipmiraw command and the ordinal numbers. :param ipmicmd: IPMI command object. :retu...
Get quantity of PCI devices. Get quantity of PCI devices of the node. :param d_info: the list of ipmitool parameters for accessing a node. :param pci_device_ids: the list contains pairs of <vendorID>/<deviceID> for PCI devices. :returns: the number of PCI devices. def get_pci_device(d_info, pci_d...
r"""Override current dict with defaults values. :param current: Current dict. :param \*args: Sequence with default data dicts. def defaults(current: dict, *args: AnyMapping) -> dict: r"""Override current dict with defaults values. :param current: Current dict. :param \*args: Sequence with default...
Provide default function for Schema validation. :param validator_class: JSONSchema suitable validator class. def validate_func_factory(validator_class: Any) -> ValidateFunc: """Provide default function for Schema validation. :param validator_class: JSONSchema suitable validator class. """ def val...
Search the CFHT archive for more images of this location def moreData(ra,dec,box): """Search the CFHT archive for more images of this location""" import cfhtCutout cdata={'ra_deg': ra, 'dec_deg': dec, 'radius_deg': 0.2} inter=cfhtCutout.find_images(cdata,0.2)
Check if xpa is running def xpacheck(): """Check if xpa is running""" import os f=os.popen('xpaaccess ds9') l=f.readline() f.close() if l.strip()!='yes': logger.debug("\t Can't get ds9 access, xpaccess said: %s" % ( l.strip())) return (False) return(True)
Mark a circle on the current image def mark(x,y,label=None): """Mark a circle on the current image""" if label is not None: os.system("xpaset -p ds9 regions color red ") cmd="echo 'image; text %d %d # text={%s}' | xpaset ds9 regions " % ( x,y,label) else: os.system("xpaset -p ds9 regions color blue...
Display a file in ds9 def display(url): """Display a file in ds9""" import os oscmd="curl --silent -g --fail --max-time 1800 --user jkavelaars '%s'" % (url) logger.debug(oscmd) os.system(oscmd+' | xpaset ds9 fits') return
Invert the transform. After calling this method, calling the instance will do the inverse transform. Calling this twice return the instance to the original transform. def inv(self): """Invert the transform. After calling this method, calling the instance will do the inverse ...
Return matrix form of the integral transform. Parameters ---------- full : bool, optional when False return two vector factors and convolution matrix separately, otherwise return full transformation matrix keeppads : bool, optional whether to keep the...
Add padding to an array. Parameters ---------- a : (..., Nin, ...) ndarray array to be padded to size `N` axis : int axis along which to pad extrap : {bool, 'const'} or 2-tuple Method to extrapolate `a`. For a 2-tuple, the two elem...
Undo padding in an array. Parameters ---------- a : (..., N, ...) ndarray array to be trimmed to size `Nin` axis : int axis along which to unpad out : bool trim the output if True, otherwise the input; the two cases have their left...
Rough sanity checks on the input function. def check(self, F): """Rough sanity checks on the input function. """ assert F.ndim == 1, "checker only supports 1D" f = self.xfac * F fabs = np.abs(f) iQ1, iQ3 = np.searchsorted(fabs.cumsum(), np.array([0.25, 0.75]) * fabs.s...
Apply an FFT along the given dimension, and with the specified amount of zero-padding Args: x (ArrayWithUnits): an :class:`~zounds.core.ArrayWithUnits` instance which has one or more :class:`~zounds.timeseries.TimeDimension` axes axis (int): The axis along which the fft ...
Create a :class:`~zounds.core.ArrayWithUnits` instance with a :class:`~zounds.timeseries.TimeDimension` and a :class:`~zounds.spectral.FrequencyDimension` representing a bank of morlet wavelets centered on the sub-bands of the scale. Args: samplerate (SampleRate): the samplerate of the input si...
Adjusts the image bias. Bias determines where the color changes start. At low bias, low intensities (i.e., low pixel values) will have non-zero color differences, while at high bias only high pixel values will have non-zero differences Args: bias: float A...
Adjusts the image contrast. Contrast refers to the rate of change of color with color level. At low contrast, color changes gradually over many intensity levels, while at high contrast it can change rapidly within a few levels Args: contrast: float A numbe...
Copies file from source to destination Args: src (str or file-like object): Source file. dst (str or file-like object): Destination file. src_is_storage (bool): Source is storage. dst_is_storage (bool): Destination is storage. def _copy(src, dst, src_is_storage, dst_is_storage): ...
Copies a source file to a destination file or directory. Equivalent to "shutil.copy". Source and destination can also be binary opened file-like objects. Args: src (path-like object or file-like object): Source file. dst (path-like object or file-like object): Destination file...
Copies a source file to a destination file. Equivalent to "shutil.copyfile". Source and destination can also be binary opened file-like objects. Args: src (path-like object or file-like object): Source file. dst (path-like object or file-like object): Destination file. follow_syml...
Handle boto exception and convert to class IO exceptions Raises: OSError subclasses: IO error. def _handle_client_error(): """ Handle boto exception and convert to class IO exceptions Raises: OSError subclasses: IO error. """ try: yield except _ClientError...
Copy object of the same storage. Args: src (str): Path or URL. dst (str): Path or URL. other_system (pycosio._core.io_system.SystemBase subclass): Unused. def copy(self, src, dst, other_system=None): """ Copy object of the same storage. Args: ...
Get base keyword arguments for client for a specific path. Args: path (str): Absolute path or URL. Returns: dict: client args def get_client_kwargs(self, path): """ Get base keyword arguments for client for a specific path. Args: ...
S3 Boto3 Session. Returns: boto3.session.Session: session def _get_session(self): """ S3 Boto3 Session. Returns: boto3.session.Session: session """ if self._session is None: self._session = _boto3.session.Session( **s...
S3 Boto3 client Returns: boto3.session.Session.client: client def _get_client(self): """ S3 Boto3 client Returns: boto3.session.Session.client: client """ client_kwargs = self._storage_parameters.get('client', dict()) # Handles unsecure...
Return URL roots for this storage. Returns: tuple of str or re.Pattern: URL roots def _get_roots(self): """ Return URL roots for this storage. Returns: tuple of str or re.Pattern: URL roots """ region = self._get_session().region_name or r'[\w-]...
Get time from header Args: header (dict): Object header. keys (tuple of str): Header keys. name (str): Method name. Returns: float: The number of seconds since the epoch def _get_time(header, keys, name): """ Get time from header ...
Returns object or bucket HTTP header. Args: client_kwargs (dict): Client arguments. Returns: dict: HTTP header. def _head(self, client_kwargs): """ Returns object or bucket HTTP header. Args: client_kwargs (dict): Client arguments. ...
Make a directory. args: client_kwargs (dict): Client arguments. def _make_dir(self, client_kwargs): """ Make a directory. args: client_kwargs (dict): Client arguments. """ with _handle_client_error(): # Object if 'Key' in...
Remove an object. args: client_kwargs (dict): Client arguments. def _remove(self, client_kwargs): """ Remove an object. args: client_kwargs (dict): Client arguments. """ with _handle_client_error(): # Object if 'Key' in c...
Lists locators. Returns: generator of tuple: locator name str, locator header dict def _list_locators(self): """ Lists locators. Returns: generator of tuple: locator name str, locator header dict """ with _handle_client_error(): resp...
Lists objects. args: client_kwargs (dict): Client arguments. path (str): Path relative to current locator. max_request_entries (int): If specified, maximum entries returned by request. Returns: generator of tuple: object name str, object ...
Read a range of bytes in stream. Args: start (int): Start stream position. end (int): End stream position. 0 To not specify end. Returns: bytes: number of bytes read def _read_range(self, start, end=0): """ Read a range of bytes in s...
Flush the write buffers of the stream if applicable. Args: buffer (memoryview): Buffer content. def _flush(self, buffer): """ Flush the write buffers of the stream if applicable. Args: buffer (memoryview): Buffer content. """ with _handle_client...
Flush the write buffers of the stream. def _flush(self): """ Flush the write buffers of the stream. """ # Initialize multi-part upload if 'UploadId' not in self._upload_args: with _handle_client_error(): self._upload_args[ 'UploadI...
Close the object in write mode. def _close_writable(self): """ Close the object in write mode. """ # Wait parts upload completion for part in self._write_futures: part['ETag'] = part.pop('response').result()['ETag'] # Complete multipart upload with _...
Handles Azure exception and convert to class IO exceptions Raises: OSError subclasses: IO error. def _handle_azure_exception(): """ Handles Azure exception and convert to class IO exceptions Raises: OSError subclasses: IO error. """ try: yield except _AzureHttpErr...
Convert properties model to dict. Args: properties: Properties model. Returns: dict: Converted model. def _properties_model_to_dict(properties): """ Convert properties model to dict. Args: properties: Properties model. Returns: dict: Converted model. """ ...
Get endpoint information from storage parameters. Update system with endpoint information and return information required to define roots. Args: self (pycosio._core.io_system.SystemBase subclass): System. sub_domain (str): Azure storage sub-domain. Returns: ...
Updates storage parameters with unsecure mode. Returns: dict: Updated storage_parameters. def _secured_storage_parameters(self): """ Updates storage parameters with unsecure mode. Returns: dict: Updated storage_parameters. """ parameters = self....
Ensure path is absolute and use the correct URL format for use with cross Azure storage account copy function. Args: path (str): Path or URL. caller_system (pycosio.storage.azure._AzureBaseSystem subclass): System calling this method (Can be another Azure system)...
Updates client kwargs for listing functions. Args: client_kwargs (dict): Client arguments. max_request_entries (int): If specified, maximum entries returned by request. Returns: dict: Updated client_kwargs def _update_listing_client_kwargs(client_kw...
Convert object model to dict. Args: obj: Object model. Returns: dict: Converted model. def _model_to_dict(obj): """ Convert object model to dict. Args: obj: Object model. Returns: dict: Converted model. """ ...
Read a range of bytes in stream. Args: start (int): Start stream position. end (int): End stream position. 0 To not specify end. Returns: bytes: number of bytes read def _read_range(self, start, end=0): """ Read a range of bytes in s...
Read and return all the bytes from the stream until EOF. Returns: bytes: Object content def _readall(self): """ Read and return all the bytes from the stream until EOF. Returns: bytes: Object content """ stream = _BytesIO() with _handle_...
Initializes file on 'a' mode. def _init_append(self): """ Initializes file on 'a' mode. """ if self._content_length: # Adjust size if content length specified with _handle_azure_exception(): self._resize( content_length=self._c...
Create the file if not exists. def _create(self): """ Create the file if not exists. """ # Create new file with _handle_azure_exception(): self._create_from_size( content_length=self._content_length, **self._client_kwargs)
Flush the write buffer of the stream if applicable. Args: buffer (memoryview): Buffer content. start (int): Start of buffer position to flush. Supported only with page blobs. end (int): End of buffer position to flush. Supported only with page...
Decorator that caches method result. Args: method (function): Method Returns: function: Memoized method. Notes: Target method class needs as "_cache" attribute (dict). It is the case of "ObjectIOBase" and all its subclasses. def memoizedmethod(method): """ Decora...
Return the previous generator object after having run the first element evaluation as a background task. Args: generator (iterable): A generator function. Returns: iterable: The generator function with first element evaluated in background. def _generat...
Handle Swift exception and convert to class IO exceptions Raises: OSError subclasses: IO error. def _handle_client_exception(): """ Handle Swift exception and convert to class IO exceptions Raises: OSError subclasses: IO error. """ try: yield except _Clien...
Copy object of the same storage. Args: src (str): Path or URL. dst (str): Path or URL. other_system (pycosio._core.io_system.SystemBase subclass): Unused. def copy(self, src, dst, other_system=None): """ Copy object of the same storage. Args: ...
Get base keyword arguments for client for a specific path. Args: path (str): Absolute path or URL. Returns: dict: client args def get_client_kwargs(self, path): """ Get base keyword arguments for client for a specific path. Args: ...
Swift client Returns: swiftclient.client.Connection: client def _get_client(self): """ Swift client Returns: swiftclient.client.Connection: client """ kwargs = self._storage_parameters # Handles unsecure mode if self._unsecure: ...
Returns object HTTP header. Args: client_kwargs (dict): Client arguments. Returns: dict: HTTP header. def _head(self, client_kwargs): """ Returns object HTTP header. Args: client_kwargs (dict): Client arguments. Returns: ...
Make a directory. args: client_kwargs (dict): Client arguments. def _make_dir(self, client_kwargs): """ Make a directory. args: client_kwargs (dict): Client arguments. """ with _handle_client_exception(): # Object if 'obj...
Remove an object. args: client_kwargs (dict): Client arguments. def _remove(self, client_kwargs): """ Remove an object. args: client_kwargs (dict): Client arguments. """ with _handle_client_exception(): # Object if 'obj' ...
Lists locators. Returns: generator of tuple: locator name str, locator header dict def _list_locators(self): """ Lists locators. Returns: generator of tuple: locator name str, locator header dict """ with _handle_client_exception(): ...
Lists objects. args: client_kwargs (dict): Client arguments. path (str): Path relative to current locator. max_request_entries (int): If specified, maximum entries returned by request. Returns: generator of tuple: object name str, object ...
Read a range of bytes in stream. Args: start (int): Start stream position. end (int): End stream position. 0 To not specify end. Returns: bytes: number of bytes read def _read_range(self, start, end=0): """ Read a range of bytes in s...
Flush the write buffers of the stream if applicable. Args: buffer (memoryview): Buffer content. def _flush(self, buffer): """ Flush the write buffers of the stream if applicable. Args: buffer (memoryview): Buffer content. """ container, obj = se...
Flush the write buffers of the stream. def _flush(self): """ Flush the write buffers of the stream. """ # Upload segment with workers name = self._segment_name % self._seek response = self._workers.submit( self._client.put_object, self._container, name, ...
Close the object in write mode. def _close_writable(self): """ Close the object in write mode. """ # Wait segments upload completion for segment in self._write_futures: segment['etag'] = segment['etag'].result() # Upload manifest file with _handle_cl...
Initializes file on 'a' mode. def _init_append(self): """ Initializes file on 'a' mode. """ # Require to load the full file content in buffer self._write_buffer[:] = self._readall() # Make initial seek position to current end of file self._seek = self._size
Flush the write buffers of the stream if applicable and close the object. def close(self): """ Flush the write buffers of the stream if applicable and close the object. """ if self._writable and not self._is_raw_of_buffered and not self._closed: self._closed ...
Return bytes from the stream without advancing the position. Args: size (int): Number of bytes to read. -1 to read the full stream. Returns: bytes: bytes read def _peek(self, size=-1): """ Return bytes from the stream without advancing the posit...
Read and return all the bytes from the stream until EOF. Returns: bytes: Object content def readall(self): """ Read and return all the bytes from the stream until EOF. Returns: bytes: Object content """ if not self._readable: raise U...
Read bytes into a pre-allocated, writable bytes-like object b, and return the number of bytes read. Args: b (bytes-like object): buffer. Returns: int: number of bytes read def readinto(self, b): """ Read bytes into a pre-allocated, writable bytes-like o...
Change the stream position to the given byte offset. Args: offset (int): Offset is interpreted relative to the position indicated by whence. whence (int): The default value for whence is SEEK_SET. Values for whence are: SEEK_SET or 0 – sta...
Update seek value. Args: offset (int): Offset. whence (int): Whence. Returns: int: Seek position. def _update_seek(self, offset, whence): """ Update seek value. Args: offset (int): Offset. whence (int): Whence. ...
Write the given bytes-like object, b, to the underlying raw stream, and return the number of bytes written. Args: b (bytes-like object): Bytes to write. Returns: int: The number of bytes written. def write(self, b): """ Write the given bytes-like object...
Check for HTTP errors and raise OSError if relevant. Args: response (requests.Response): Returns: requests.Response: response def _handle_http_errors(response): """ Check for HTTP errors and raise OSError if relevant. Args: response (requests.Response): Retur...
Returns object HTTP header. Args: client_kwargs (dict): Client arguments. Returns: dict: HTTP header. def _head(self, client_kwargs): """ Returns object HTTP header. Args: client_kwargs (dict): Client arguments. Returns: ...
Read a range of bytes in stream. Args: start (int): Start stream position. end (int): End stream position. 0 To not specify end. Returns: bytes: number of bytes read def _read_range(self, start, end=0): """ Read a range of bytes in s...
Read and return all the bytes from the stream until EOF. Returns: bytes: Object content def _readall(self): """ Read and return all the bytes from the stream until EOF. Returns: bytes: Object content """ return _handle_http_errors( s...
Flush the write buffers of the stream if applicable and save the object on the cloud. def flush(self): """ Flush the write buffers of the stream if applicable and save the object on the cloud. """ if self._writable: with self._seek_lock: buffe...
Change the stream position to the given byte offset. Args: offset (int): Offset is interpreted relative to the position indicated by whence. whence (int): The default value for whence is SEEK_SET. Values for whence are: SEEK_SET or 0 – sta...
Flush the write buffers of the stream if applicable. In write mode, send the buffer content to the cloud object. def _flush(self): """ Flush the write buffers of the stream if applicable. In write mode, send the buffer content to the cloud object. """ # Flush buffer to...
Keep track of the file size during writing. If specified size value is greater than the current size, update the current size using specified value. Used as callback in default "_flush" implementation for files supporting random write access. Args: size (int): Size...
Flush a buffer to a range of the file. Meant to be used asynchronously, used to provides parallel flushing of file parts when applicable. Args: buffer (memoryview): Buffer content. start (int): Start of buffer position to flush. end (int): End of buffer posi...