sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def extract_flatfield(prihdr, scihdu):
"""Extract flatfield data from ``PFLTFILE``.
Parameters
----------
prihdr : obj
FITS primary header HDU.
scihdu : obj
Extension HDU of the science image.
This is only used to extract subarray data.
Returns
-------
invflat ... | Extract flatfield data from ``PFLTFILE``.
Parameters
----------
prihdr : obj
FITS primary header HDU.
scihdu : obj
Extension HDU of the science image.
This is only used to extract subarray data.
Returns
-------
invflat : ndarray or `None`
Inverse flatfield,... | entailment |
def from_irafpath(irafpath):
"""Resolve IRAF path like ``jref$`` into actual file path.
Parameters
----------
irafpath : str
Path containing IRAF syntax.
Returns
-------
realpath : str
Actual file path. If input does not follow ``path$filename``
format, then this is... | Resolve IRAF path like ``jref$`` into actual file path.
Parameters
----------
irafpath : str
Path containing IRAF syntax.
Returns
-------
realpath : str
Actual file path. If input does not follow ``path$filename``
format, then this is the same as input.
Raises
... | entailment |
def extract_ref(scihdu, refhdu):
"""Extract section of the reference image that
corresponds to the given science image.
This only returns a view, not a copy of the
reference image's array.
Parameters
----------
scihdu, refhdu : obj
Extension HDU's of the science and reference image... | Extract section of the reference image that
corresponds to the given science image.
This only returns a view, not a copy of the
reference image's array.
Parameters
----------
scihdu, refhdu : obj
Extension HDU's of the science and reference image,
respectively.
Returns
... | entailment |
def find_line(scihdu, refhdu):
"""Obtain bin factors and corner location to extract
and bin the appropriate subset of a reference image to
match a science image.
If the science image has zero offset and is the same size and
binning as the reference image, ``same_size`` will be set to
`True`. Ot... | Obtain bin factors and corner location to extract
and bin the appropriate subset of a reference image to
match a science image.
If the science image has zero offset and is the same size and
binning as the reference image, ``same_size`` will be set to
`True`. Otherwise, the values of ``rx``, ``ry``,... | entailment |
def get_corner(hdr, rsize=1):
"""Obtain bin and corner information for a subarray.
``LTV1``, ``LTV2``, ``LTM1_1``, and ``LTM2_2`` keywords
are extracted from the given extension header and converted
to bin and corner values (0-indexed).
``LTV1`` for the CCD uses the beginning of the illuminated
... | Obtain bin and corner information for a subarray.
``LTV1``, ``LTV2``, ``LTM1_1``, and ``LTM2_2`` keywords
are extracted from the given extension header and converted
to bin and corner values (0-indexed).
``LTV1`` for the CCD uses the beginning of the illuminated
portion as the origin, not the begi... | entailment |
def get_lt(hdr):
"""Obtain the LTV and LTM keyword values.
Note that this returns the values just as read from the header,
which means in particular that the LTV values are for one-indexed
pixel coordinates.
LTM keywords are the diagonal elements of MWCS linear
transformation matrix, while LTV... | Obtain the LTV and LTM keyword values.
Note that this returns the values just as read from the header,
which means in particular that the LTV values are for one-indexed
pixel coordinates.
LTM keywords are the diagonal elements of MWCS linear
transformation matrix, while LTV's are MWCS linear trans... | entailment |
def from_lt(rsize, ltm, ltv):
"""Compute the corner location and pixel size in units
of unbinned pixels.
.. note:: Translated from ``calacs/lib/fromlt.c``.
Parameters
----------
rsize : int
Reference pixel size. Usually 1.
ltm, ltv : tuple of float
See :func:`get_lt`.
... | Compute the corner location and pixel size in units
of unbinned pixels.
.. note:: Translated from ``calacs/lib/fromlt.c``.
Parameters
----------
rsize : int
Reference pixel size. Usually 1.
ltm, ltv : tuple of float
See :func:`get_lt`.
Returns
-------
bin : tuple ... | entailment |
def hdr_vals_for_overscan(root):
"""Retrieve header keyword values from RAW and SPT
FITS files to pass on to :func:`check_oscntab` and
:func:`check_overscan`.
Parameters
----------
root : str
Rootname of the observation. Can be relative path
to the file excluding the type of FIT... | Retrieve header keyword values from RAW and SPT
FITS files to pass on to :func:`check_oscntab` and
:func:`check_overscan`.
Parameters
----------
root : str
Rootname of the observation. Can be relative path
to the file excluding the type of FITS file and
extension, e.g., '/my... | entailment |
def check_oscntab(oscntab, ccdamp, xsize, ysize, leading, trailing):
"""Check if the supplied parameters are in the
``OSCNTAB`` reference file.
.. note:: Even if an entry does not exist in ``OSCNTAB``,
as long as the subarray does not have any overscan,
it should not be a proble... | Check if the supplied parameters are in the
``OSCNTAB`` reference file.
.. note:: Even if an entry does not exist in ``OSCNTAB``,
as long as the subarray does not have any overscan,
it should not be a problem for CALACS.
.. note:: This function does not check the virtual bias r... | entailment |
def check_overscan(xstart, xsize, total_prescan_pixels=24,
total_science_pixels=4096):
"""Check image for bias columns.
Parameters
----------
xstart : int
Starting column of the readout in detector coordinates.
xsize : int
Number of columns in the readout.
t... | Check image for bias columns.
Parameters
----------
xstart : int
Starting column of the readout in detector coordinates.
xsize : int
Number of columns in the readout.
total_prescan_pixels : int
Total prescan pixels for a single amplifier on a detector.
Default is 2... | entailment |
def process_request(self, request):
"""
Ignore unnecessary actions for static file requests, posts, or ajax
requests. We're only interested in redirecting following a 'natural'
request redirection to the `wagtailadmin_explore_root` or
`wagtailadmin_explore` views.
"""
... | Ignore unnecessary actions for static file requests, posts, or ajax
requests. We're only interested in redirecting following a 'natural'
request redirection to the `wagtailadmin_explore_root` or
`wagtailadmin_explore` views. | entailment |
def acs2d(input, exec_path='', time_stamps=False, verbose=False, quiet=False,
exe_args=None):
r"""
Run the acs2d.e executable as from the shell.
Output is automatically named based on input suffix:
+--------------------+----------------+------------------------------+
| INPUT ... | r"""
Run the acs2d.e executable as from the shell.
Output is automatically named based on input suffix:
+--------------------+----------------+------------------------------+
| INPUT | OUTPUT | EXPECTED DATA |
+====================+================+=... | entailment |
def run(configobj=None):
"""
TEAL interface for the `acs2d` function.
"""
acs2d(configobj['input'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
quiet=configobj['quiet']
) | TEAL interface for the `acs2d` function. | entailment |
def run(configobj=None):
"""
TEAL interface for the `acscte` function.
"""
acscte(configobj['input'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
quiet=configobj['quiet'],
single_core=config... | TEAL interface for the `acscte` function. | entailment |
def _check_inputs(self):
"""Check the inputs to ensure they are valid.
Returns
-------
status : bool
True if all inputs are valid, False if one is not.
"""
valid_detector = True
valid_filter = True
valid_date = True
# Determine the su... | Check the inputs to ensure they are valid.
Returns
-------
status : bool
True if all inputs are valid, False if one is not. | entailment |
def _check_date(self, fmt='%Y-%m-%d'):
"""Convenience method for determining if the input date is valid.
Parameters
----------
fmt : str
The format of the date string. The default is ``%Y-%m-%d``, which
corresponds to ``YYYY-MM-DD``.
Returns
----... | Convenience method for determining if the input date is valid.
Parameters
----------
fmt : str
The format of the date string. The default is ``%Y-%m-%d``, which
corresponds to ``YYYY-MM-DD``.
Returns
-------
status : str or `None`
If ... | entailment |
def _submit_request(self):
"""Submit a request to the ACS Zeropoint Calculator.
If an exception is raised during the request, an error message is
given. Otherwise, the response is saved in the corresponding
attribute.
"""
try:
self._response = urlopen(self._... | Submit a request to the ACS Zeropoint Calculator.
If an exception is raised during the request, an error message is
given. Otherwise, the response is saved in the corresponding
attribute. | entailment |
def _parse_and_format(self):
""" Parse and format the results returned by the ACS Zeropoint Calculator.
Using ``beautifulsoup4``, find all the ``<tb> </tb>`` tags present in
the response. Format the results into an astropy.table.QTable with
corresponding units and assign it to the zpt_t... | Parse and format the results returned by the ACS Zeropoint Calculator.
Using ``beautifulsoup4``, find all the ``<tb> </tb>`` tags present in
the response. Format the results into an astropy.table.QTable with
corresponding units and assign it to the zpt_table attribute. | entailment |
def fetch(self):
"""Submit the request to the ACS Zeropoints Calculator.
This method will:
* submit the request
* parse the response
* format the results into a table with the correct units
Returns
-------
tab : `astropy.table.QTable` or `None`
... | Submit the request to the ACS Zeropoints Calculator.
This method will:
* submit the request
* parse the response
* format the results into a table with the correct units
Returns
-------
tab : `astropy.table.QTable` or `None`
If the request was succe... | entailment |
def get_queryset(self, request):
"""
Returns a QuerySet of all model instances that can be edited by the
admin site.
"""
qs = self.model._default_manager.get_queryset()
ordering = self.get_ordering(request)
if ordering:
qs = qs.order_by(*ordering)
... | Returns a QuerySet of all model instances that can be edited by the
admin site. | entailment |
def index_view(self, request):
"""
Instantiates a class-based view to provide listing functionality for
the assigned model. The view class used can be overridden by changing
the 'index_view_class' attribute.
"""
kwargs = {'model_admin': self}
view_class = self.ind... | Instantiates a class-based view to provide listing functionality for
the assigned model. The view class used can be overridden by changing
the 'index_view_class' attribute. | entailment |
def create_view(self, request):
"""
Instantiates a class-based view to provide 'creation' functionality for
the assigned model, or redirect to Wagtail's create view if the
assigned model extends 'Page'. The view class used can be overridden by
changing the 'create_view_class' att... | Instantiates a class-based view to provide 'creation' functionality for
the assigned model, or redirect to Wagtail's create view if the
assigned model extends 'Page'. The view class used can be overridden by
changing the 'create_view_class' attribute. | entailment |
def choose_parent_view(self, request):
"""
Instantiates a class-based view to provide a view that allows a parent
page to be chosen for a new object, where the assigned model extends
Wagtail's Page model, and there is more than one potential parent for
new instances. The view cla... | Instantiates a class-based view to provide a view that allows a parent
page to be chosen for a new object, where the assigned model extends
Wagtail's Page model, and there is more than one potential parent for
new instances. The view class used can be overridden by changing the
'choose_p... | entailment |
def edit_view(self, request, object_id):
"""
Instantiates a class-based view to provide 'edit' functionality for the
assigned model, or redirect to Wagtail's edit view if the assigned
model extends 'Page'. The view class used can be overridden by changing
the 'edit_view_class' a... | Instantiates a class-based view to provide 'edit' functionality for the
assigned model, or redirect to Wagtail's edit view if the assigned
model extends 'Page'. The view class used can be overridden by changing
the 'edit_view_class' attribute. | entailment |
def confirm_delete_view(self, request, object_id):
"""
Instantiates a class-based view to provide 'delete confirmation'
functionality for the assigned model, or redirect to Wagtail's delete
confirmation view if the assigned model extends 'Page'. The view class
used can be overrid... | Instantiates a class-based view to provide 'delete confirmation'
functionality for the assigned model, or redirect to Wagtail's delete
confirmation view if the assigned model extends 'Page'. The view class
used can be overridden by changing the 'confirm_delete_view_class'
attribute. | entailment |
def unpublish_view(self, request, object_id):
"""
Instantiates a class-based view that redirects to Wagtail's 'unpublish'
view for models that extend 'Page' (if the user has sufficient
permissions). We do this via our own view so that we can reliably
control redirection of the us... | Instantiates a class-based view that redirects to Wagtail's 'unpublish'
view for models that extend 'Page' (if the user has sufficient
permissions). We do this via our own view so that we can reliably
control redirection of the user back to the index_view once the action
is completed. Th... | entailment |
def copy_view(self, request, object_id):
"""
Instantiates a class-based view that redirects to Wagtail's 'copy'
view for models that extend 'Page' (if the user has sufficient
permissions). We do this via our own view so that we can reliably
control redirection of the user back to... | Instantiates a class-based view that redirects to Wagtail's 'copy'
view for models that extend 'Page' (if the user has sufficient
permissions). We do this via our own view so that we can reliably
control redirection of the user back to the index_view once the action
is completed. The vie... | entailment |
def get_templates(self, action='index'):
"""
Utility function that provides a list of templates to try for a given
view, when the template isn't overridden by one of the template
attributes on the class.
"""
app = self.opts.app_label
model_name = self.opts.model_n... | Utility function that provides a list of templates to try for a given
view, when the template isn't overridden by one of the template
attributes on the class. | entailment |
def get_permissions_for_registration(self):
"""
Utilised by Wagtail's 'register_permissions' hook to allow permissions
for a model to be assigned to groups in settings. This is only required
if the model isn't a Page model, and isn't registered as a Snippet
"""
from wagta... | Utilised by Wagtail's 'register_permissions' hook to allow permissions
for a model to be assigned to groups in settings. This is only required
if the model isn't a Page model, and isn't registered as a Snippet | entailment |
def get_admin_urls_for_registration(self):
"""
Utilised by Wagtail's 'register_admin_urls' hook to register urls for
our the views that class offers.
"""
urls = (
url(get_url_pattern(self.opts),
self.index_view, name=get_url_name(self.opts)),
... | Utilised by Wagtail's 'register_admin_urls' hook to register urls for
our the views that class offers. | entailment |
def get_menu_item(self):
"""
Utilised by Wagtail's 'register_menu_item' hook to create a menu
for this group with a SubMenu linking to listing pages for any
associated ModelAdmin instances
"""
if self.modeladmin_instances:
submenu = SubMenu(self.get_submenu_it... | Utilised by Wagtail's 'register_menu_item' hook to create a menu
for this group with a SubMenu linking to listing pages for any
associated ModelAdmin instances | entailment |
def get_permissions_for_registration(self):
"""
Utilised by Wagtail's 'register_permissions' hook to allow permissions
for a all models grouped by this class to be assigned to Groups in
settings.
"""
qs = Permission.objects.none()
for instance in self.modeladmin_i... | Utilised by Wagtail's 'register_permissions' hook to allow permissions
for a all models grouped by this class to be assigned to Groups in
settings. | entailment |
def get_admin_urls_for_registration(self):
"""
Utilised by Wagtail's 'register_admin_urls' hook to register urls for
used by any associated ModelAdmin instances
"""
urls = []
for instance in self.modeladmin_instances:
urls.extend(instance.get_admin_urls_for_re... | Utilised by Wagtail's 'register_admin_urls' hook to register urls for
used by any associated ModelAdmin instances | entailment |
def is_shown(self, request):
"""
If there aren't any visible items in the submenu, don't bother to show
this menu item
"""
for menuitem in self.menu._registered_menu_items:
if menuitem.is_shown(request):
return True
return False | If there aren't any visible items in the submenu, don't bother to show
this menu item | entailment |
def run(configobj=None):
"""
TEAL interface for the `acscteforwardmodel` function.
"""
acscteforwardmodel(configobj['input'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
... | TEAL interface for the `acscteforwardmodel` function. | entailment |
def run(configobj=None):
"""
TEAL interface for the `acsccd` function.
"""
acsccd(configobj['input'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
quiet=configobj['quiet'] #,
#dqicorr=config... | TEAL interface for the `acsccd` function. | entailment |
def destripe_plus(inputfile, suffix='strp', stat='pmode1', maxiter=15,
sigrej=2.0, lower=None, upper=None, binwidth=0.3,
scimask1=None, scimask2=None,
dqbits=None, rpt_clean=0, atol=0.01,
cte_correct=True, clobber=False, verbose=True):
r"""Cali... | r"""Calibrate post-SM4 ACS/WFC exposure(s) and use
standalone :ref:`acsdestripe`.
This takes a RAW image and generates a FLT file containing
its calibrated and destriped counterpart.
If CTE correction is performed, FLC will also be present.
Parameters
----------
inputfile : str or list of ... | entailment |
def run(configobj=None):
"""TEAL interface for :func:`destripe_plus`."""
destripe_plus(
configobj['input'],
suffix=configobj['suffix'],
stat=configobj['stat'],
maxiter=configobj['maxiter'],
sigrej=configobj['sigrej'],
lower=configobj['lower'],
upper=config... | TEAL interface for :func:`destripe_plus`. | entailment |
def main():
"""Command line driver."""
import argparse
# Parse input parameters
parser = argparse.ArgumentParser(
prog=__taskname__,
description=(
'Run CALACS and standalone acs_destripe script on given post-SM4 '
'ACS/WFC RAW full-frame or supported subarray ima... | Command line driver. | entailment |
def get_search_results(self, request, queryset, search_term):
"""
Returns a tuple containing a queryset to implement the search,
and a boolean indicating if the results may contain duplicates.
"""
# Apply keyword searches.
def construct_search(field_name):
if ... | Returns a tuple containing a queryset to implement the search,
and a boolean indicating if the results may contain duplicates. | entailment |
def get_filters_params(self, params=None):
"""
Returns all params except IGNORED_PARAMS
"""
if not params:
params = self.params
lookup_params = params.copy() # a dictionary of the query string
# Remove all the parameters that are globally and systematically
... | Returns all params except IGNORED_PARAMS | entailment |
def get_ordering_field(self, field_name):
"""
Returns the proper model field name corresponding to the given
field_name to use for ordering. field_name may either be the name of a
proper model field or the name of a method (on the admin or model) or a
callable with the 'admin_ord... | Returns the proper model field name corresponding to the given
field_name to use for ordering. field_name may either be the name of a
proper model field or the name of a method (on the admin or model) or a
callable with the 'admin_order_field' attribute. Returns None if no
proper model f... | entailment |
def get_ordering(self, request, queryset):
"""
Returns the list of ordering fields for the change list.
First we check the get_ordering() method in model admin, then we check
the object's default ordering. Then, any manually-specified ordering
from the query string overrides anyt... | Returns the list of ordering fields for the change list.
First we check the get_ordering() method in model admin, then we check
the object's default ordering. Then, any manually-specified ordering
from the query string overrides anything. Finally, a deterministic
order is guaranteed by e... | entailment |
def get_ordering_field_columns(self):
"""
Returns an OrderedDict of ordering field column numbers and asc/desc
"""
# We must cope with more than one column having the same underlying
# sort field, so we base things on column numbers.
ordering = self._get_default_ordering... | Returns an OrderedDict of ordering field column numbers and asc/desc | entailment |
def get_field_label(self, field_name, field=None):
""" Return a label to display for a field """
label = None
if field is not None:
label = getattr(field, 'verbose_name', None)
if label is None:
label = getattr(field, 'name', None)
if label is None... | Return a label to display for a field | entailment |
def get_field_display_value(self, field_name, field=None):
""" Return a display value for a field """
"""
Firstly, check for a 'get_fieldname_display' property/method on
the model, and return the value of that, if present.
"""
val_funct = getattr(self.instance, 'get_%s_d... | Return a display value for a field | entailment |
def get_image_field_display(self, field_name, field):
""" Render an image """
image = getattr(self.instance, field_name)
if image:
fltr, _ = Filter.objects.get_or_create(spec='max-400x400')
rendition = image.get_rendition(fltr)
return rendition.img_tag
... | Render an image | entailment |
def get_document_field_display(self, field_name, field):
""" Render a link to a document """
document = getattr(self.instance, field_name)
if document:
return mark_safe(
'<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % (
document.url,
... | Render a link to a document | entailment |
def get_dict_for_field(self, field_name):
"""
Return a dictionary containing `label` and `value` values to display
for a field.
"""
try:
field = self.model._meta.get_field(field_name)
except FieldDoesNotExist:
field = None
return {
... | Return a dictionary containing `label` and `value` values to display
for a field. | entailment |
def get_fields_dict(self):
"""
Return a list of `label`/`value` dictionaries to represent the
fiels named by the model_admin class's `get_inspect_view_fields` method
"""
fields = []
for field_name in self.model_admin.get_inspect_view_fields():
fields.append(se... | Return a list of `label`/`value` dictionaries to represent the
fiels named by the model_admin class's `get_inspect_view_fields` method | entailment |
def items_for_result(view, result):
"""
Generates the actual list of data.
"""
model_admin = view.model_admin
for field_name in view.list_display:
empty_value_display = model_admin.get_empty_value_display()
row_classes = ['field-%s' % field_name]
try:
f, attr, val... | Generates the actual list of data. | entailment |
def result_list(context):
"""
Displays the headers and data list together
"""
view = context['view']
object_list = context['object_list']
headers = list(result_headers(view))
num_sorted_fields = 0
for h in headers:
if h['sortable'] and h['sorted']:
num_sorted_fields +... | Displays the headers and data list together | entailment |
def run(configobj=None):
"""
TEAL interface for the `acssum` function.
"""
acssum(configobj['input'],
configobj['output'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
quiet=configobj['quiet'... | TEAL interface for the `acssum` function. | entailment |
def _detsat_one(filename, ext, sigma=2.0, low_thresh=0.1, h_thresh=0.5,
small_edge=60, line_len=200, line_gap=75,
percentile=(4.5, 93.0), buf=200, plot=False, verbose=False):
"""Called by :func:`detsat`."""
if verbose:
t_beg = time.time()
fname = '{0}[{1}]'.format(fi... | Called by :func:`detsat`. | entailment |
def _get_valid_indices(shape, ix0, ix1, iy0, iy1):
"""Give array shape and desired indices, return indices that are
correctly bounded by the shape."""
ymax, xmax = shape
if ix0 < 0:
ix0 = 0
if ix1 > xmax:
ix1 = xmax
if iy0 < 0:
iy0 = 0
if iy1 > ymax:
iy1 = ym... | Give array shape and desired indices, return indices that are
correctly bounded by the shape. | entailment |
def _rotate_point(point, angle, ishape, rshape, reverse=False):
"""Transform a point from original image coordinates to rotated image
coordinates and back. It assumes the rotation point is the center of an
image.
This works on a simple rotation transformation::
newx = (startx) * np.cos(angle) ... | Transform a point from original image coordinates to rotated image
coordinates and back. It assumes the rotation point is the center of an
image.
This works on a simple rotation transformation::
newx = (startx) * np.cos(angle) - (starty) * np.sin(angle)
newy = (startx) * np.sin(angle) + (s... | entailment |
def make_mask(filename, ext, trail_coords, sublen=75, subwidth=200, order=3,
sigma=4, pad=10, plot=False, verbose=False):
"""Create DQ mask for an image for a given satellite trail.
This mask can be added to existing DQ data using :func:`update_dq`.
.. note::
Unlike :func:`detsat`, m... | Create DQ mask for an image for a given satellite trail.
This mask can be added to existing DQ data using :func:`update_dq`.
.. note::
Unlike :func:`detsat`, multiprocessing is not available for
this function.
Parameters
----------
filename : str
FITS image filename.
... | entailment |
def update_dq(filename, ext, mask, dqval=16384, verbose=True):
"""Update the given image and DQ extension with the given
satellite trails mask and flag.
Parameters
----------
filename : str
FITS image filename to update.
ext : int, str, or tuple
DQ extension, as accepted by ``a... | Update the given image and DQ extension with the given
satellite trails mask and flag.
Parameters
----------
filename : str
FITS image filename to update.
ext : int, str, or tuple
DQ extension, as accepted by ``astropy.io.fits``, to update.
mask : ndarray
Boolean mask,... | entailment |
def _satdet_worker(work_queue, done_queue, sigma=2.0, low_thresh=0.1,
h_thresh=0.5, small_edge=60, line_len=200, line_gap=75,
percentile=(4.5, 93.0), buf=200):
"""Multiprocessing worker."""
for fil, chip in iter(work_queue.get, 'STOP'):
try:
result = _de... | Multiprocessing worker. | entailment |
def detsat(searchpattern, chips=[1, 4], n_processes=4, sigma=2.0,
low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200,
line_gap=75, percentile=(4.5, 93.0), buf=200, plot=False,
verbose=True):
"""Find satellite trails in the given images and extensions.
The trails are calcu... | Find satellite trails in the given images and extensions.
The trails are calculated using Probabilistic Hough Transform.
.. note::
The trail endpoints found here are crude approximations.
Use :func:`make_mask` to create the actual DQ mask for the trail(s)
of interest.
Parameters
... | entailment |
def on(self, event: str) -> Callable:
""" Decorator for subscribing a function to a specific event.
:param event: Name of the event to subscribe to.
:type event: str
:return: The outer function.
:rtype: Callable
"""
def outer(func):
self.add_event(f... | Decorator for subscribing a function to a specific event.
:param event: Name of the event to subscribe to.
:type event: str
:return: The outer function.
:rtype: Callable | entailment |
def add_event(self, func: Callable, event: str) -> None:
""" Adds a function to a event.
:param func: The function to call when event is emitted
:type func: Callable
:param event: Name of the event.
:type event: str
"""
self._events[event].add(func) | Adds a function to a event.
:param func: The function to call when event is emitted
:type func: Callable
:param event: Name of the event.
:type event: str | entailment |
def emit(self, event: str, *args, **kwargs) -> None:
""" Emit an event and run the subscribed functions.
:param event: Name of the event.
:type event: str
.. notes:
Passing in threads=True as a kwarg allows to run emitted events
as separate threads. This can sig... | Emit an event and run the subscribed functions.
:param event: Name of the event.
:type event: str
.. notes:
Passing in threads=True as a kwarg allows to run emitted events
as separate threads. This can significantly speed up code execution
depending on the c... | entailment |
def emit_only(self, event: str, func_names: Union[str, List[str]], *args,
**kwargs) -> None:
""" Specifically only emits certain subscribed events.
:param event: Name of the event.
:type event: str
:param func_names: Function(s) to emit.
:type func_names: Unio... | Specifically only emits certain subscribed events.
:param event: Name of the event.
:type event: str
:param func_names: Function(s) to emit.
:type func_names: Union[ str | List[str] ] | entailment |
def emit_after(self, event: str) -> Callable:
""" Decorator that emits events after the function is completed.
:param event: Name of the event.
:type event: str
:return: Callable
.. note:
This plainly just calls functions without passing params into the
... | Decorator that emits events after the function is completed.
:param event: Name of the event.
:type event: str
:return: Callable
.. note:
This plainly just calls functions without passing params into the
subscribed callables. This is great if you want to do som... | entailment |
def remove_event(self, func_name: str, event: str) -> None:
""" Removes a subscribed function from a specific event.
:param func_name: The name of the function to be removed.
:type func_name: str
:param event: The name of the event.
:type event: str
:raise EventDoesntE... | Removes a subscribed function from a specific event.
:param func_name: The name of the function to be removed.
:type func_name: str
:param event: The name of the event.
:type event: str
:raise EventDoesntExist if there func_name doesn't exist in event. | entailment |
def _event_funcs(self, event: str) -> Iterable[Callable]:
""" Returns an Iterable of the functions subscribed to a event.
:param event: Name of the event.
:type event: str
:return: A iterable to do things with.
:rtype: Iterable
"""
for func in self._events[event... | Returns an Iterable of the functions subscribed to a event.
:param event: Name of the event.
:type event: str
:return: A iterable to do things with.
:rtype: Iterable | entailment |
def _event_func_names(self, event: str) -> List[str]:
""" Returns string name of each function subscribed to an event.
:param event: Name of the event.
:type event: str
:return: Names of functions subscribed to a specific event.
:rtype: list
"""
return [func.__n... | Returns string name of each function subscribed to an event.
:param event: Name of the event.
:type event: str
:return: Names of functions subscribed to a specific event.
:rtype: list | entailment |
def _subscribed_event_count(self) -> int:
""" Returns the total amount of subscribed events.
:return: Integer amount events.
:rtype: int
"""
event_counter = Counter() # type: Dict[Any, int]
for key, values in self._events.items():
event_counter[key] = len(v... | Returns the total amount of subscribed events.
:return: Integer amount events.
:rtype: int | entailment |
def clean(input, suffix, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3,
mask1=None, mask2=None, dqbits=None,
rpt_clean=0, atol=0.01, clobber=False, verbose=True):
r"""Remove horizontal stripes from ACS WFC post-SM4 data.
Parameters
----------
... | r"""Remove horizontal stripes from ACS WFC post-SM4 data.
Parameters
----------
input : str or list of str
Input filenames in one of these formats:
* a Python list of filenames
* a partial filename with wildcards ('\*flt.fits')
* filename of an ASN table ('j1234... | entailment |
def perform_correction(image, output, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3,
mask=None, dqbits=None,
rpt_clean=0, atol=0.01, clobber=False, verbose=True):
"""
Clean each input image.
Parameters
--... | Clean each input image.
Parameters
----------
image : str
Input image name.
output : str
Output image name.
mask : `numpy.ndarray`
Mask array.
maxiter, sigrej, clobber
See :func:`clean`.
dqbits : int, str, or None
Data quality bits to be considere... | entailment |
def clean_streak(image, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3, mask=None,
rpt_clean=0, atol=0.01, verbose=True):
"""
Apply destriping algorithm to input array.
Parameters
----------
image : `StripeArray` object
Arrays a... | Apply destriping algorithm to input array.
Parameters
----------
image : `StripeArray` object
Arrays are modifed in-place.
stat : str
Statistics for background computations
(see :py:func:`clean` for more details)
mask : `numpy.ndarray`
Mask array. Pixels with zero ... | entailment |
def djs_iterstat(InputArr, MaxIter=10, SigRej=3.0,
Max=None, Min=None, Mask=None, lineno=None):
"""
Iterative sigma-clipping.
Parameters
----------
InputArr : `numpy.ndarray`
Input image array.
MaxIter, SigRej : see `clean`
Max, Min : float
Max and min val... | Iterative sigma-clipping.
Parameters
----------
InputArr : `numpy.ndarray`
Input image array.
MaxIter, SigRej : see `clean`
Max, Min : float
Max and min values for clipping.
Mask : `numpy.ndarray`
Mask array to indicate pixels to reject, in addition to clipping.
... | entailment |
def run(configobj=None):
"""TEAL interface for the `clean` function."""
clean(configobj['input'],
suffix=configobj['suffix'],
stat=configobj['stat'],
maxiter=configobj['maxiter'],
sigrej=configobj['sigrej'],
lower=configobj['lower'],
upper=configobj['u... | TEAL interface for the `clean` function. | entailment |
def main():
"""Command line driver."""
import argparse
parser = argparse.ArgumentParser(
prog=__taskname__,
description='Remove horizontal stripes from ACS WFC post-SM4 data.')
parser.add_argument(
'arg0', metavar='input', type=str, help='Input file')
parser.add_argument(
... | Command line driver. | entailment |
def configure_arrays(self):
"""Get the SCI and ERR data."""
self.science = self.hdulist['sci', 1].data
self.err = self.hdulist['err', 1].data
self.dq = self.hdulist['dq', 1].data
if (self.ampstring == 'ABCD'):
self.science = np.concatenate(
(self.scien... | Get the SCI and ERR data. | entailment |
def ingest_flatfield(self):
"""Process flatfield."""
self.invflat = extract_flatfield(
self.hdulist[0].header, self.hdulist[1])
# If BIAS or DARK, set flatfield to unity
if self.invflat is None:
self.invflat = np.ones_like(self.science)
return
... | Process flatfield. | entailment |
def ingest_flash(self):
"""Process post-flash."""
self.flash = extract_flash(self.hdulist[0].header, self.hdulist[1])
# Set post-flash to zeros
if self.flash is None:
self.flash = np.zeros_like(self.science)
return
# Apply the flash subtraction if neces... | Process post-flash. | entailment |
def ingest_dark(self):
"""Process dark."""
self.dark = extract_dark(self.hdulist[0].header, self.hdulist[1])
# If BIAS or DARK, set dark to zeros
if self.dark is None:
self.dark = np.zeros_like(self.science)
return
# Apply the dark subtraction if necess... | Process dark. | entailment |
def write_corrected(self, output, clobber=False):
"""Write out the destriped data."""
# un-apply the flatfield if necessary
if self.flatcorr != 'COMPLETE':
self.science = self.science / self.invflat
self.err = self.err / self.invflat
# un-apply the post-flash if... | Write out the destriped data. | entailment |
def calacs(input_file, exec_path=None, time_stamps=False, temp_files=False,
verbose=False, debug=False, quiet=False, single_core=False,
exe_args=None):
"""
Run the calacs.e executable as from the shell.
By default this will run the calacs given by 'calacs.e'.
Parameters
-----... | Run the calacs.e executable as from the shell.
By default this will run the calacs given by 'calacs.e'.
Parameters
----------
input_file : str
Name of input file.
exec_path : str, optional
The complete path to a calacs executable.
time_stamps : bool, optional
Set to T... | entailment |
def run(configobj=None):
"""
TEAL interface for the `calacs` function.
"""
calacs(configobj['input_file'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
temp_files=configobj['temp_files'],
verbose=configobj['verbose'],
deb... | TEAL interface for the `calacs` function. | entailment |
def has_any_permissions(self, user):
"""
Return a boolean to indicate whether the supplied user has any
permissions at all on the associated model
"""
for perm in self.get_all_model_permissions():
if self.has_specific_permission(user, perm.codename):
r... | Return a boolean to indicate whether the supplied user has any
permissions at all on the associated model | entailment |
def get_valid_parent_pages(self, user):
"""
Identifies possible parent pages for the current user by first looking
at allowed_parent_page_models() on self.model to limit options to the
correct type of page, then checking permissions on those individual
pages to make sure we have ... | Identifies possible parent pages for the current user by first looking
at allowed_parent_page_models() on self.model to limit options to the
correct type of page, then checking permissions on those individual
pages to make sure we have permission to add a subpage to it. | entailment |
def acsrej(input, output, exec_path='', time_stamps=False, verbose=False,
shadcorr=False, crrejtab='', crmask=False, scalense=None,
initgues='', skysub='', crsigmas='', crradius=None, crthresh=None,
badinpdq=None, newbias=False, readnoise_only=False, exe_args=None):
r"""
Run the... | r"""
Run the acsrej.e executable as from the shell.
Parameters
----------
input : str or list of str
Input filenames in one of these formats:
* a Python list of filenames
* a partial filename with wildcards ('\*flt.fits')
* filename of an ASN table ('j123456... | entailment |
def run(configobj=None):
"""
TEAL interface for the `acsrej` function.
"""
acsrej(configobj['input'],
configobj['output'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
shadcorr=configobj['sha... | TEAL interface for the `acsrej` function. | entailment |
def monkeypatch_os_fork_functions():
"""
Replace os.fork* with wrappers that use ForkSafeLock to acquire
all locks before forking and release them afterwards.
"""
builtin_function = type(''.join)
if hasattr(os, 'fork') and isinstance(os.fork, builtin_function):
global _orig_os_fork
... | Replace os.fork* with wrappers that use ForkSafeLock to acquire
all locks before forking and release them afterwards. | entailment |
def atfork(prepare=None, parent=None, child=None):
"""A Python work-a-like of pthread_atfork.
Any time a fork() is called from Python, all 'prepare' callables will
be called in the order they were registered using this function.
After the fork (successful or not), all 'parent' callables will be ca... | A Python work-a-like of pthread_atfork.
Any time a fork() is called from Python, all 'prepare' callables will
be called in the order they were registered using this function.
After the fork (successful or not), all 'parent' callables will be called in
the parent process. If the fork succeeded, al... | entailment |
def _call_atfork_list(call_list):
"""
Given a list of callables in call_list, call them all in order and save
and return a list of sys.exc_info() tuples for each exception raised.
"""
exception_list = []
for func in call_list:
try:
func()
except:
exception... | Given a list of callables in call_list, call them all in order and save
and return a list of sys.exc_info() tuples for each exception raised. | entailment |
def parent_after_fork_release():
"""
Call all parent after fork callables, release the lock and print
all prepare and parent callback exceptions.
"""
prepare_exceptions = list(_prepare_call_exceptions)
del _prepare_call_exceptions[:]
exceptions = _call_atfork_list(_parent_call_list)
_for... | Call all parent after fork callables, release the lock and print
all prepare and parent callback exceptions. | entailment |
def _print_exception_list(exceptions, message, output_file=None):
"""
Given a list of sys.exc_info tuples, print them all using the traceback
module preceeded by a message and separated by a blank line.
"""
output_file = output_file or sys.stderr
message = 'Exception %s:\n' % message
for exc... | Given a list of sys.exc_info tuples, print them all using the traceback
module preceeded by a message and separated by a blank line. | entailment |
def os_forkpty_wrapper():
"""Wraps os.forkpty() to run atfork handlers."""
pid = None
prepare_to_fork_acquire()
try:
pid, fd = _orig_os_forkpty()
finally:
if pid == 0:
child_after_fork_release()
else:
parent_after_fork_release()
return pid, fd | Wraps os.forkpty() to run atfork handlers. | entailment |
def maybe(value):
"""Wraps an object with a Maybe instance.
>>> maybe("I'm a value")
Something("I'm a value")
>>> maybe(None);
Nothing
Testing for value:
>>> maybe("I'm a value").is_some()
True
>>> maybe("I'm a value").is_none()
False
>>> may... | Wraps an object with a Maybe instance.
>>> maybe("I'm a value")
Something("I'm a value")
>>> maybe(None);
Nothing
Testing for value:
>>> maybe("I'm a value").is_some()
True
>>> maybe("I'm a value").is_none()
False
>>> maybe(None).is_some()
... | entailment |
def setup(self):
'''Called after instantiation'''
TelnetHandlerBase.setup(self)
# Spawn a greenlet to handle socket input
self.greenlet_ic = eventlet.spawn(self.inputcooker)
# Note that inputcooker exits on EOF
# Sleep for 0.5 second to allow options negotiation
... | Called after instantiation | entailment |
def inputcooker_store_queue(self, char):
"""Put the cooked data in the input queue (no locking needed)"""
if type(char) in [type(()), type([]), type("")]:
for v in char:
self.cookedq.put(v)
else:
self.cookedq.put(char) | Put the cooked data in the input queue (no locking needed) | entailment |
def setup(self):
'''Setup the connection.'''
log.debug( 'New request from address %s, port %d', self.client_address )
try:
self.transport.load_server_moduli()
except:
log.exception( '(Failed to load moduli -- gex will be unsupported.)' )
rais... | Setup the connection. | entailment |
def streamserver_handle(cls, socket, address):
'''Translate this class for use in a StreamServer'''
request = cls.dummy_request()
request._sock = socket
server = None
cls(request, address, server) | Translate this class for use in a StreamServer | entailment |
def check_channel_shell_request(self, channel):
'''Request to start a shell on the given channel'''
try:
self.channels[channel].start()
except KeyError:
log.error('Requested to start a channel (%r) that was not previously set up.', channel)
return False
... | Request to start a shell on the given channel | entailment |
def check_channel_pty_request(self, channel, term, width, height, pixelwidth,
pixelheight, modes):
'''Request to allocate a PTY terminal.'''
#self.sshterm = term
#print "term: %r, modes: %r" % (term, modes)
log.debug('PTY requested. Setting up %r.', sel... | Request to allocate a PTY terminal. | entailment |
def download(url, file_name):
r = requests.get(url, stream=True)
file_size = int(r.headers['Content-length'])
'''
if py3:
file_size = int(u.getheader("Content-Length")[0])
else:
file_size = int(u.info().getheaders("Content-Length")[0])
'''
file_exists = False
if... | if py3:
file_size = int(u.getheader("Content-Length")[0])
else:
file_size = int(u.info().getheaders("Content-Length")[0]) | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.