output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
Parse the result table create source objects and observations. | Given the following Python 3 function, write the documentation
def parse(self, ssos_result_filename_or_lines, mpc_observations=None):
table_reader = ascii.get_reader(Reader=ascii.Basic)
table_reader.inconsistent_handler = self._skip_missing_data
table_reader.header.splitter.delimiter = '\t'
... | As a python code expert, you are capable of creating scripts from specifications. |
Search for frames take after the given date. | Make a summary of the following Python 3 code
def search_end_date(self, search_end_date):
assert isinstance(search_end_date, Time)
self._search_end_date = search_end_date.replicate(format='iso')
self._search_end_date.out_subfmt = 'date' | You are a Python code generator, capable of creating scripts from specifications. |
Returns a dictionary of SSOS query parameters. | Can you generate a brief explanation for the following Python 3 code
def params(self):
params = dict(format=RESPONSE_FORMAT,
verbose=self.verbose,
epoch1=str(self.search_start_date),
epoch2=str(self.search_end_date),
search=... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get(self):
"""
:return: A string containing the TSV result from SSOS
:rtype: str
:raise: AssertionError
"""
params = self.param_dict_builder.params
logger.debug(pprint.pformat(format(params)))
response = requests.post(SSOS_URL,
... | Create a Python 3 function for
getting the TSV result from the SSOS parameter dictionary. | You are a Python code architect, reviewing and designing scalable and efficient code |
Over - rides normal behaviour of shifting focus to any child. | Can you generate a brief explanation for the following Python 3 code
def SetFocus(self, **kwargs):
if self._focus is not None:
self._focus.SetFocus()
else:
# fall back on the default behaviour
super(_FocusablePanel, self).SetFocus() | As a Python code translator, you convert algorithms and pseudocode into Python. |
run the actual step3 of the ISO search | Here you have a function in Python 3, explain what it does
def step3(expnums, ccd, version, rate_min,
rate_max, angle, width, field=None, prefix=None, dry_run=False,
maximum_flux_ratio=3, minimum_area=5, minimum_median_flux=1000.0):
"""run the actual step3 on the given exp/ccd combo"""
jmp... | As a Python code composer, you craft elegant and concise scripts. |
def extract_init_args(instance):
"""
Given an instance, and under the assumption that member variables have the
same name as the __init__ arguments, extract the arguments so they can
be used to reconstruct the instance when deserializing
"""
cls = instance.__class__
args = [x for x in inspec... | Can you implement a function in Python 3 that
gives an instance extract the arguments that can be reconstructed by deserializing it | You are a Python code analyst, evaluating scripts for potential improvements. |
Display list of choices. As many as we can get in a page. | Given the following Python 3 function, write the documentation
def list(self,header,choices):
"Display list of choices. As many as we can get in a page."
if not self.__list_window:
(y,x)=self.__main.getmaxyx()
self.__list_window = self.__main.subwin(35,x,0,0)
... | You are a Python code generator, capable of creating scripts from specifications. |
def recenter(self):
"""
Reset the reference position values to correspond to the center
of the reference frame.
Algorithm used here developed by Colin Cox - 27-Jan-2004.
"""
if self.ctype1.find('TAN') < 0 or self.ctype2.find('TAN') < 0:
print 'WCS.recenter() o... | Can you write a function in Python 3 where it
recenters the reference position values for the center pixel of the reference frame. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Builds a new keyword based on original keyword name and
a prepend string. | Make a summary of the following Python 3 code
def _buildNewKeyname(self,key,prepend):
if len(prepend+key) <= 8: _new_key = prepend+key
else: _new_key = str(prepend+key)[:8]
return _new_key | As a python code expert, you are capable of creating scripts from specifications. |
Makes a deep copy of this object for use by other objects. | Can you generate the documentation for the following Python 3 function
def copy(self,deep=yes):
if deep:
return copy.deepcopy(self)
else:
return copy.copy(self) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def scrambleTriples(expnums,ccd):
"""Pull the three images and then scramble the MJD-OBS keywords"""
import pyfits, MOPfits
mjd=[]
fid=[]
fs=[]
filenames=[]
for expnum in expnums:
if int(ccd)<18:
cutout="[-*,-*]"
else:
cutout="[*,*]"
filenames.... | Write a Python 3 script to
pull the three images and then scramble the MJD - OBS keywords | As a python code expert, you are capable of creating scripts from specifications. |
def getTriples(expnums,ccd):
"""Pull the three images and then scramble the MJD-OBS keywords"""
import pyfits, MOPfits
filenames=[]
for expnum in expnums:
if int(ccd)<18:
cutout="[-*,-*]"
else:
cutout="[*,*]"
filenames.append(MOPfits.adGet(str(expnum)+opt.... | Write a Python 3 function that can
pull the three images and then scramble the MJD - OBS keywords | As a python code expert, you are capable of creating scripts from specifications. |
This function searches for all the Triples in a set of exposures and returns a list of the KBOs that are found in that set. | Can you generate the documentation for the following Python 3 function
def searchTriples(filenames,plant=False):
print filenames
if opt.none :
return
import MOPfits,os
import MOPdbaccess
import string
import os.path
import pyfits
if len(filenames)!=3:
raise Task... | You are a Python code architect, reviewing and designing scalable and efficient code |
Ushort a the pixels | Explain what the following Python 3 code does
def ushort(filename):
import pyfits
f=pyfits.open(filename,mode='update')
f[0].scale('int16','',bzero=32768)
f.flush()
f.close() | As a Python code composer, you craft elegant and concise scripts. |
def parse(self, filename):
"""
Parses a file into an AstromData structure.
Args:
filename: str
The name of the file whose contents will be parsed.
Returns:
data: AstromData
The file contents extracted into a data structure for programmatic
... | How would you implement a function in Python 3 that
parses a file into an AstromData structure. | As a Python code composer, you craft elegant and concise scripts. |
def _write_observation_headers(self, observations):
"""
See src/pipematt/step1matt-c
"""
for observation in observations:
header = observation.header
def get_header_vals(header_list):
header_vals = []
for key in header_list:
... | Can you write a function in Python 3 where it
writes the header of the MJD - Obs model. | As a Python code analyst, you investigate and solve complex coding mysteries |
Write the sys header. | Make a summary of the following Python 3 code
def _write_sys_header(self, sys_header):
header_vals = [sys_header[RMIN], sys_header[RMAX], sys_header[ANGLE],
sys_header[AWIDTH]]
self._write_line("## RMIN RMAX ANGLE AWIDTH")
self._write_line("# %8.1f%8.1f%8.1f%8.1... | As a python code expert, you are capable of creating scripts from specifications. |
Write the source data to the file. | Can you generate a brief explanation for the following Python 3 code
def _write_source_data(self, sources):
for i, source in enumerate(sources):
self._write_source(source) | You are a Python code generator, capable of creating scripts from specifications. |
def write_headers(self, observations, sys_header):
"""
Writes the header part of the astrom file so that only the source
data has to be filled in.
"""
if self._header_written:
raise AstromFormatError("Astrom file already has headers.")
self._write_observation... | Write a Python 3 script to
write the header part of the astrom file so that only the sourceCOOKIE and sourceCOOKIE are written. | You are a Python code analyst, evaluating scripts for potential improvements. |
Writes out data for a single source. | Make a summary of the following Python 3 code
def write_source(self, source):
if not self._header_written:
observations = [reading.get_observation() for reading in source.get_readings()]
self.write_headers(observations, self.sys_header)
self._write_source(source) | As a python code expert, you are capable of creating scripts from specifications. |
Writes an AstromData structure at once. | Make a summary of the following Python 3 code
def write_astrom_data(self, astrom_data):
self.write_headers(astrom_data.observations, astrom_data.sys_header)
self._write_source_data(astrom_data.sources) | As a python code expert, you are capable of creating scripts from specifications. |
def _original_frame(self, x, y):
"""
Return x/y in the original frame, based on a guess as much as anything.
:param x: x pixel coordinate
:type x: float
:param y: y pixel coordinate
:type y: float
:return: x,y
:rtype: float, float
"""
if se... | How would you implement a function in Python 3 that
returns x y in the original frame based on a guess as much as anything. | You are a Python code generator, capable of creating scripts from specifications. |
def pix_coord(self, pix_coord):
"""
:type pix_coord: list
:param pix_coord: an x,y pixel coordinate, origin = 1
"""
try:
pix_coord = list(pix_coord)
except:
pass
if not isinstance(pix_coord, list) or len(pix_coord) != 2:
raise V... | Create a Python 3 function for
setting the _pix_coord attribute of the object | You are a Python code generator, capable of creating scripts from specifications. |
def reference_source_point(self):
"""
The location of the source in the reference image, in terms of the
current image coordinates.
"""
xref = isinstance(self.xref, Quantity) and self.xref.value or self.xref
yref = isinstance(self.yref, Quantity) and self.yref.value or se... | Implement a Python 3 function for
returning the location of the source in terms of the reference image coordinates. | As a Python code analyst, you investigate and solve complex coding mysteries |
Calculates the x and y offsets between this reading and the other reading s base - point of the other reading. | Explain what the following Python 3 code does
def get_coordinate_offset(self, other_reading):
my_x, my_y = self.reference_source_point
other_x, other_y = other_reading.reference_source_point
return my_x - other_x, my_y - other_y | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns:
inverted: bool
True if the stored image is inverted. | Make a summary of the following Python 3 code
def compute_inverted(self):
# astheader = storage.get_astheader(self.obs.expnum, self.obs.ccdnum, version=self.obs.ftype)
# pvwcs = wcs.WCS(astheader)
# (x, y) = pvwcs.sky2xy(self.ra, self.dec)
# logger.debug("is_inverted: X,Y {},{} -> wcs X... | As a python code expert, you are capable of creating scripts from specifications. |
Given the location of a source in the image create an Observation object and return it. | Here you have a function in Python 3, explain what it does
def from_source_reference(expnum, ccd, x, y):
image_uri = storage.dbimages_uri(expnum=expnum,
ccd=None,
version='p',
ext='.fits',... | As a python code expert, you are capable of creating scripts from specifications. |
Writes out data for a single source. | Can you generate the documentation for the following Python 3 function
def write_source(self, source, comment=None, reject=False):
if not self._header_written:
observations = [reading.get_observation() for reading in source.get_readings()]
self.write_headers(observations, self.sys_header... | You are a Python code architect, reviewing and designing scalable and efficient code |
Convert Modfied Juian Date to GMST. | Given the following Python 3 function, write the documentation
def mjd2gmst(mjd):
tu = (mjd - MJD0) / (100*DPY)
st = math.fmod(mjd, 1.0) * D2PI + (24110.54841 + (8640184.812866 + (0.093104 - 6.2e-6 * tu) * tu) * tu) * DS2R
w = math.fmod(st, D2PI)
if w >= 0.0:
return w
else:
return... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Compute the norm of the gradients for each sample in a batch and penalize anything on either side of unit norm | Explain what the following Python 3 code does
def _gradient_penalty(self, real_samples, fake_samples, kwargs):
import torch
from torch.autograd import Variable, grad
real_samples = real_samples.view(fake_samples.shape)
subset_size = real_samples.shape[0]
real_samples = real_sa... | You are a Python code generator, capable of creating scripts from specifications. |
Compute the RA and DEC of the line of the given astrometric line. | How would you explain what the following Python 3 function does
def remeasure(mpc_in, reset_pixel_coordinates=True):
if mpc_in.null_observation:
return mpc_in
mpc_obs = deepcopy(mpc_in)
logging.debug("rm start: {}".format(mpc_obs.to_string()))
if not isinstance(mpc_obs.comment, mp_ephem.ephem.O... | As a python code expert, you are capable of creating scripts from specifications. |
def _connection_error_wrapper(func, *args, **kwargs):
"""
Wrap a call to func in a try/except that repeats on ConnectionError
@param func:
@param args:
@param kwargs:
@return:
"""
counter = 0
while counter < 5:
try:
result = func(*args, **kwargs)
retu... | Implement a function in Python 3 to
wrap a call to func in a try / except that repeats on ConnectionError and logs a warning if the call fails. | As a Python code composer, you craft elegant and concise scripts. |
Get the mag of the object given the mp_ephem. ephem. Observation object. | Can you generate a brief explanation for the following Python 3 code
def recompute_mag(mpc_in, skip_centroids=False):
# TODO this really shouldn't need to build a 'reading' to get the cutout...
from ossos.downloads.cutouts import downloader
dlm = downloader.ImageCutoutDownloader()
mpc_obs = deepcopy(m... | As a Python code analyst, you investigate and solve complex coding mysteries |
Compare the orbit fit given the original astrometry and modified astrometry. | How would you explain what the following Python 3 function does
def compare_orbits(original_obs, modified_obs, cor_file):
origin = orbfit.Orbfit(original_obs)
modified = orbfit.Orbfit(modified_obs)
orbpt = file(cor_file+".orb", 'w')
# Dump summaries of the orbits
orbpt.write("#"*80+"\n")
orbp... | You are a Python code analyst, evaluating scripts for potential improvements. |
def mono(self):
"""
Return this instance summed to mono. If the instance is already mono,
this is a no-op.
"""
if self.channels == 1:
return self
x = self.sum(axis=1) * 0.5
y = x * 0.5
return AudioSamples(y, self.samplerate) | Write a Python 3 function for
returning this instance summed to mono. | As a Python code analyst, you investigate and solve complex coding mysteries |
def encode(self, flo=None, fmt='WAV', subtype='PCM_16'):
"""
Return audio samples encoded as bytes given a particular audio format
Args:
flo (file-like): A file-like object to write the bytes to. If flo
is not supplied, a new :class:`io.BytesIO` instance will be
... | Can you create a Python 3 function that
returns audio samples encoded as bytes given a particular audio format | As a Python code composer, you craft elegant and concise scripts. |
Extend the given validator class with default values. | Explain what the following Python 3 code does
def extend_with_default(validator_class: Any) -> Any:
validate_properties = validator_class.VALIDATORS['properties']
def set_defaults(validator: Any,
properties: dict,
instance: dict,
schema: dict) -> I... | As a Python code composer, you craft elegant and concise scripts. |
Compute weights given a scale or time - frequency representation
| Can you generate a brief explanation for the following Python 3 code
def weights(self, other):
try:
return self._wdata(other)
except AttributeError:
frequency_dim = other.dimensions[-1]
return self._wdata(frequency_dim.scale) | As a python code expert, you are capable of creating scripts from specifications. |
def rates_angles(fk_candidate_observations):
"""
:param fk_candidate_observations: name of the fk*reals.astrom file to check against Object.planted
"""
detections = fk_candidate_observations.get_sources()
for detection in detections:
measures = detection.get_readings()
for measure i... | Can you create a Python 3 function that
returns a list of rates angles for each source in the fk*reals. astrom file. | You are a Python code generator, capable of creating scripts from specifications. |
def download_hdulist(self, uri, **kwargs):
"""
Downloads a FITS image as a HDUList.
Args:
uri: The URI of the FITS image to download.
kwargs: optional arguments to pass to the vos client.
For example, passing view="cutout" and cutout=[1] will result
i... | Can you write a function in Python 3 where it
downloads a FITS image as a HDUList. | As a Python code analyst, you investigate and solve complex coding mysteries |
Downloads the apcor data. | Explain what the following Python 3 code does
def download_apcor(self, uri):
local_file = os.path.basename(uri)
if os.access(local_file, os.F_OK):
fobj = open(local_file)
else:
fobj = storage.vofile(uri, view='data')
fobj.seek(0)
str = fobj.read()
... | As a Python code composer, you craft elegant and concise scripts. |
Creates an ApcorData record from the raw string format. | Here you have a function in Python 3, explain what it does
def from_string(cls, rawstr):
try:
args = map(float, rawstr.split())
except Exception as ex:
import sys
logger.error("Failed to convert aperture correction: {}".format(ex))
raise ex
return ... | You are a Python code architect, reviewing and designing scalable and efficient code |
def run(expnum, ccd, version, dry_run=False, prefix="", force=False):
"""Run the OSSOS jmpmakepsf script.
"""
message = storage.SUCCESS
if storage.get_status(task, prefix, expnum, version=version, ccd=ccd) and not force:
logging.info("{} completed successfully for {} {} {} {}".format(task, pre... | Can you write a function in Python 3 where it
runs the OSSOS jmpmakepsf script. | You are a Python code architect, reviewing and designing scalable and efficient code |
def run(expnum, ccd, version, dry_run=False, prefix="", force=False, ignore_dependency=False):
"""Run the OSSOS mopheader script.
"""
message = storage.SUCCESS
logging.info("Attempting to get status on header for {} {}".format(expnum, ccd))
if storage.get_status(task, prefix, expnum, version, ccd) ... | Can you write a function in Python 3 where it
runs the OSSOS mopheader script. | You are a Python code architect, reviewing and designing scalable and efficient code |
Compute htm index of htm_level at position ra dec | Explain what the following Python 3 code does
def htmIndex(ra,dec,htm_level=3):
import re
if os.uname()[0] == "Linux": javabin = '/opt/java2/bin/java '
htm_level = htm_level
verc_htm_cmd = javabin+'-classpath /usr/cadc/misc/htm/htmIndex.jar edu.jhu.htm.app.lookup %s %s %s' % (htm_level, ra, dec)
fo... | You are a Python code analyst, evaluating scripts for potential improvements. |
Convert an image to a cutout | Make a summary of the following Python 3 code
def circTOcutout(wcs,ra,dec,rad):
(x1,y1)=wcs.rd2xy((ra+rad/2.0,dec-rad/2.0))
(x2,y2)=wcs.rd2xy((ra-rad/2.0,dec+rad/2.0))
xl=min(x1,x2)
xr=max(x1,x2)
yl=min(y1,y2)
yu=max(y1,y2)
### constrain the cutout to be inside the image
x1=max(xl,1... | As a Python code analyst, you investigate and solve complex coding mysteries |
def predict(abg,date,obs=568):
"""Run GB's predict using an ABG file as input."""
import orbfit
import RO.StringUtil
(ra,dec,a,b,ang) = orbfit.predict(abg,date,obs)
obj['RA']=ra
obj['DEC']=dec
obj['dRA']=a
obj['dDEC']=b
obj['dANG']=ang
return obj | Can you write a function in Python 3 where it
runs GB s predict using an ABG file as input. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def config_logging(level):
"""
Configure the logging given the level desired
"""
logger = logging.getLogger('')
logger.setLevel(level)
if level < logging.DEBUG:
log_format = "%(asctime)s %(message)s"
else:
log_format = "%(asctime)s %(module)s : %(lineno)d %(message)s"
s... | Write a Python 3 script to
configure the logging given the level desired | You are a Python code generator, capable of creating scripts from specifications. |
def exec_prog(args):
"""Run a subprocess, check for .OK and raise error if does not exist.
args: list of arguments, for value is the command to execute.
"""
program_name = args[0]
logging.info(" ".join(args))
output = subprocess.check_output(args, stderr=subprocess.STDOUT)
if not os.acces... | Create a Python 3 function to
execute a subprocess and return the output. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_pixel_bounds_from_datasec_keyword(datasec):
"""
Return the x/y pixel boundaries of the data section.
:param datasec: str e.g. '[33:2080,1:4612]'
:return: ((xmin,xmax),(ymin,ymax))
"""
datasec = re.findall(r'(\d+)', datasec)
x1 = min(int(datasec[0]), int(datasec[1]))
x2 = max(int(... | How would you code a function in Python 3 to
return the x y pixel boundaries of the data section. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def match_lists(pos1, pos2, tolerance=MATCH_TOLERANCE, spherical=False):
"""
Given two sets of x/y positions match the lists, uniquely.
:rtype : numpy.ma, numpy.ma
:param pos1: list of x/y positions.
:param pos2: list of x/y positions.
:param tolerance: float distance, in pixels, to consider a ... | Write a Python 3 script for
giving two sets of x and y positions match the lists uniquely. | As a python code expert, you are capable of creating scripts from specifications. |
Returns a stream to write the log content. | Make a summary of the following Python 3 code
def stream(self):
if self._stream is None:
self._stream = tempfile.NamedTemporaryFile(delete=False)
try:
self._stream.write(self.client.open(self.filename, view='data').read())
except:
pass
re... | You are a Python code analyst, evaluating scripts for potential improvements. |
Return the client object for this instance. | Here you have a function in Python 3, explain what it does
def client(self):
if self._client is not None:
return self._client
self._client = vospace.client
return self._client | As a Python code composer, you craft elegant and concise scripts. |
Read time from a single string using a set of possible formats. | Can you generate a brief explanation for the following Python 3 code
def parse_string(self, timestr, subfmts):
# Datetime components required for conversion to JD by ERFA, along
# with the default values.
components = ('year', 'mon', 'mday')
defaults = (None, 1, 1, 0)
# Assume th... | You are a Python code generator, capable of creating scripts from specifications. |
Parse through the command line arguments to over -ride the values
in the users. dbrc file. | Explain what the following Python 3 code does
def _get_db_options(args):
import optik, getpass,sys
from optik import OptionParser
parser=OptionParser()
parser.add_option("-d","--database",
action="store", type="string", dest="database",
default="cfht",
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Read through the users. dbrc file to get the password for the db and user. | Explain what the following Python 3 code does
def _get_db_password(dbSystem,db,user):
import string, getpass, os
dbrc = os.environ['HOME']+"/.dbrc"
password={}
if os.access(dbrc,os.R_OK):
fd=open(dbrc)
lines=fd.readlines()
for line in lines:
entry=line.split()
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def _get_db_connect(dbSystem,db,user,password):
"""Create a connection to the database specified on the command line
"""
if dbSystem=='SYBASE':
import Sybase
try:
dbh = Sybase.connect(dbSystem,
user,
password,
... | Can you implement a function in Python 3 that
creates a connection to the database specified on the command line | As a Python code composer, you craft elegant and concise scripts. |
Builds a sequence of TSVs from a CADC file. | Here you have a function in Python 3, explain what it does
def caom2(mpc_filename, search_date="2014 07 24.0"):
columns = ('Image',
'Ext',
'X',
'Y',
'MJD',
'Filter',
'Exptime',
'Object_RA',
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Downloads a cutout of the FITS image for a given source reading. | Given the following Python 3 function, write the documentation
def download_cutout(self, reading, focus=None, needs_apcor=False):
logger.debug("Doing download_cutout with inputs: reading:{} focus:{} needs_apcor:{}".format(reading,
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Load the targets from a file. | How would you explain what the following Python 3 function does
def load_objects(self, directory_name=None):
# for name in Neptune:
# self.kbos[name] = Neptune[name]
if directory_name is not None:
# defaults to looking at .ast files only
if directory_name == paramete... | As a Python code analyst, you investigate and solve complex coding mysteries |
convert from plot to canvas coordinates. | Explain what the following Python 3 code does
def p2c(self, p=None):
if p is None:
p = [0, 0]
x = (p[0] - self.x1) * self.xscale + self.cx1
y = (p[1] - self.y1) * self.yscale + self.cy1
# logging.debug("p2c: ({},{}) -> ({},{})".format(p[0],p[1], x, y))
return (x, y) | You are a Python code architect, reviewing and designing scalable and efficient code |
Convert from plot to screen coordinates | How would you explain what the following Python 3 function does
def p2s(self, p=None):
if not p: p = [0, 0]
s = self.p2c(p)
return self.c2s(s) | You are a Python code architect, reviewing and designing scalable and efficient code |
Convert from canvas to screen coordinates | Here you have a function in Python 3, explain what it does
def c2s(self, p=None):
if not p:
p = [0, 0]
return p[0] - self.canvasx(self.cx1), p[1] - self.canvasy(self.cy2) | You are a Python code generator, capable of creating scripts from specifications. |
Return the RA and DEC of the center of the visible Canvas. | How would you explain what the following Python 3 function does
def centre(self):
return self.p2s(self.canvasx(self.width / 2.0)), self.p2s(self.canvasy(self.height / 2.0)) | You are a Python code architect, reviewing and designing scalable and efficient code |
def coord_grid(self):
"""Draw a grid of RA/DEC on Canvas."""
ra2 = math.pi * 2
ra1 = 0
dec1 = -1 * math.pi / 2.0
dec2 = math.pi / 2.0
dra = math.fabs((self.x2 - self.x1) / 4.0)
ddec = math.fabs((self.y2 - self.y1) / 4.0)
logging.debug("Drawing the grid."... | Write a Python 3 function that can
draw a grid of the current RA and DEC on Canvas. | You are a Python code architect, reviewing and designing scalable and efficient code |
def tickmark(self, x, y, size=10, orientation=90):
"""Draw a line of size and orientation at x,y"""
(x1, y1) = self.p2c([x, y])
x2 = x1 + size * math.cos(math.radians(orientation))
y2 = y1 - size * math.sin(math.radians(orientation))
self.create_line(x1, y1, x2, y2) | Write a Python 3 script for
drawing a line of size and orientation at x y | As a Python code translator, you convert algorithms and pseudocode into Python. |
def limits(self, x1, x2, y1, y2):
"""Set the coordinate boundaries of plot"""
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.y2 - self.y1)
# Determ... | Implement a function in Python 3 to
set the coordinate boundaries of the plot | You are a Python code analyst, evaluating scripts for potential improvements. |
Expand to the full scale | Can you generate a brief explanation for the following Python 3 code
def reset(self):
sun = ephem.Sun()
this_time = Time(self.date.get(), scale='utc')
sun.compute(this_time.iso)
self.sun = Coord((sun.ra, sun.dec))
self.doplot()
self.plot_pointings() | As a Python code analyst, you investigate and solve complex coding mysteries |
Update the search box with the current object | Explain what the following Python 3 code does
def updateObj(self, event):
name = self.objList.get("active")
self.SearchVar.set(name)
self.object_info.set(str(self.kbos.get(name, '')))
return | As a Python code analyst, you investigate and solve complex coding mysteries |
Move to the position of the KBO. | Can you generate the documentation for the following Python 3 function
def relocate(self):
name = self.SearchVar.get()
if self.kbos.has_key(name):
kbo = self.kbos[name]
assert isinstance(kbo, orbfit.Orbfit)
this_time = Time(self.date.get(), scale='utc')
t... | As a python code expert, you are capable of creating scripts from specifications. |
Zoom in the area of the current area. | Can you generate a brief explanation for the following Python 3 code
def zoom(self, event=None, scale=2.0):
# compute the x,y of the center of the screen
sx1 = (self.cx1 + self.cx2) / 2.0
sy1 = (self.cy1 + self.cy2) / 2.0
if not event is None:
logging.debug("EVENT: {},{}".f... | You are a Python code generator, capable of creating scripts from specifications. |
def create_point(self, xcen, ycen, size=10, color='red', fill=None):
"""Plot a circle of size at this x,y location"""
if fill is None:
fill = color
(x, y) = self.p2c((xcen, ycen))
x1 = x - size
x2 = x + size
y1 = y - size
y2 = y + size
self.c... | Write a Python 3 script for
creating a circle of size at this x y location | You are a Python code generator, capable of creating scripts from specifications. |
def current_pointing(self, index):
"""set the color of the currently selected pointing to 'blue'"""
if self.current is not None:
for item in self.pointings[self.current]['items']:
self.itemconfigure(item, outline="black")
self.current = index
for item in self.... | Create a Python 3 function for
setting the color of the currently selected pointing to black | As a python code expert, you are capable of creating scripts from specifications. |
Delete the currently active pointing | Explain what the following Python 3 code does
def delete_pointing(self, event):
if self.current is None:
return
for item in self.pointings[self.current]['items']:
self.delete(item)
self.delete(self.pointings[self.current]['label']['id'])
del (self.pointings[self.... | As a Python code analyst, you investigate and solve complex coding mysteries |
Load some pointings from a file. | Here you have a function in Python 3, explain what it does
def load_pointings(self, filename=None):
filename = ( filename is None and tkFileDialog.askopenfilename() or filename)
if filename is None:
return
f = storage.open_vos_or_local(filename)
lines = f.readlines()
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def create_pointing(self, event, label_text=None):
"""Plot the sky coverage of pointing at event.x,event.y on the canvas.
"""
x = self.canvasx(event.x)
y = self.canvasy(event.y)
(ra, dec) = self.c2p((x, y))
this_camera = Camera(ra=float(ra) * units.radian, dec=float(dec)... | Write a Python 3 function for
creating the pointing area for the current camera. | You are a Python code architect, reviewing and designing scalable and efficient code |
Plot pointings on canavs | Can you generate the documentation for the following Python 3 function
def plot_pointings(self, pointings=None):
if pointings is None:
pointings = self.pointings
i = 0
for pointing in pointings:
items = []
i = i + 1
label = {}
label['... | As a Python code analyst, you investigate and solve complex coding mysteries |
def set_pointing_label(self):
"""Let the label of the current pointing to the value in the plabel box"""
current = self.current
pointing = self.pointings[current]
self.delete_pointing(None)
pointing["label"]['text'] = self.plabel.get()
self.pointings.append(pointing)
... | Can you implement a function in Python 3 that
lets the label of the current pointing to the value in the plabel box | As a Python code analyst, you investigate and solve complex coding mysteries |
def move_pointing(self, event):
"""Grab nearest pointing to event.x,event.y and with cursor"""
(ra, dec) = self.c2p((self.canvasx(event.x),
self.canvasy(event.y)))
closest = None
this_pointing = None
this_index = -1
index = -1
for po... | Can you create a Python 3 function that
moves the nearest pointing to event. x event. y and with cursor. | You are a Python code architect, reviewing and designing scalable and efficient code |
def ossos_pointings(self):
"""
plot an OSSOS observation on the OSSOS plot.
"""
match = re.match('(\d+)\D(\d+)', self.expnum.get())
if match is not None:
expnum = int(match.group(1))
ccd = int(match.group(2))
x = 2112 / 2.0
y = 4644... | Write a Python 3 function that can
plot an OSSOS observation on the OSSOS plot. | You are a Python code architect, reviewing and designing scalable and efficient code |
def get_pointings(self):
"""
Retrieve the MEGACAM pointings that overlap with the current FOV and plot.
@return: None
"""
self.camera.set("MEGACAM_40")
(ra1, dec1) = self.c2p((self.canvasx(1), self.canvasy(1)))
(ra2, dec2) = self.c2p((self.canvasx(480 * 2), self.... | Can you create a Python 3 function that
retrieves the MEGACAM pointings that overlap with the current FOV and plot. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Print the currently defined FOVs and the mean position of target KBOs in this field. | Make a summary of the following Python 3 code
def save_pointings(self):
i = 0
if self.pointing_format.get() in ['GEMINI ET', 'CFHT ET', 'CFHT API']:
logging.info('Beginning table pointing save.')
for pointing in self.pointings:
name = pointing["label"]["text"]
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def doplot(self):
"""
Clear the plot and then redraw it.
"""
w = self
w.delete(ALL)
w.coord_grid()
w.objList.delete(0, END)
self._plot() | Create a Python 3 function for
clearing the plot and redraw it. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def _plot(self):
"""Draw the actual plot.
"""
w = self
kbos = self.kbos
re_string = w.FilterVar.get()
vlist = []
for name in kbos:
if not re.search(re_string, name):
continue
vlist.append(name)
fill = None
... | Create a Python 3 function to
draw the actual plot. | As a Python code translator, you convert algorithms and pseudocode into Python. |
This function takes a fk_candidate_observations and matches the Object. planted file with found sources. | Can you generate a brief explanation for the following Python 3 code
def planted(fk_candidate_observations, planted_objects, tolerance=10):
found_pos = []
detections = fk_candidate_observations.get_sources()
for detection in detections:
reading = detection.get_reading(0)
# create a list of ... | You are a Python code analyst, evaluating scripts for potential improvements. |
def mjd2gmst(mjd):
"""Convert Modfied Juian Date (JD = 2400000.5) to GMST
Take from P.T. Walace routines"""
D2PI= 6.2831853071795864769252867665590057683943387987502
DS2R= 7.2722052166430399038487115353692196393452995355905e-5
tu = (mjd-51544.5)/36525.0;
st = fmod(mjd,1.0) * ... | Write a Python 3 function that can
convert Modfied Juian Date to GMST. | You are a Python code analyst, evaluating scripts for potential improvements. |
Convert ecliptic coordinates to equatorial coordinates | Explain what the following Python 3 code does
def ec2eq(self):
import math
#from numpy.matlib import sin, cos, arcsin, arctan2
from math import sin, cos
from math import asin as arcsin
from math import atan2 as arctan2
from math import acos as arccos
eb=... | As a Python code composer, you craft elegant and concise scripts. |
def plot_line(axes, fname, ltype):
"""plot the ecliptic plane line on the given axes."""
x = np.genfromtxt(fname, unpack=True)
axes.plot(x[0], x[1], ltype) | Can you write a function in Python 3 where it
plots the ecliptic plane line on the given axes | As a Python code translator, you convert algorithms and pseudocode into Python. |
def apmag_at_absmag(H, d, phi=1):
"""
Calculate the apparent magnitude of a TNO given its absolute magnitude H, for a given distance.
:param H: TNO absolute magnitude (unitless)
:param d: barycentric distance (AU)
:param phi: phase angle (0-1, always v close to 1 for TNOs)
:return: apparent mag... | Implement a Python 3 function for
calculating the apparent magnitude of a TNO given its absolute magnitude H and a given distance d. | As a python code expert, you are capable of creating scripts from specifications. |
Create a new instance of the class from a summary line. | Here you have a function in Python 3, explain what it does
def from_summary_line(cls, summaryLine, version=4, existing_object=None):
''' Summary format:
object mag stdev dist ..E nobs time av_xres av_yres max_x max_y
a ..E e ..E i ..E node ..E argperi ..E M ... | You are a Python code architect, reviewing and designing scalable and efficient code |
def from_class_line(cls, classLine, version=4, existing_object=None):
'''
Class format:
class wrt n m security object mag stdev F H_sur dist ..E nobs time av_xres av_yres max_x max_y
a ..E e ..E i ..E node ..E argperi ..E time_peri .... | Can you write a function in Python 3 where it
creates a new instance of the class from a class line. | As a python code expert, you are capable of creating scripts from specifications. |
execute SCCI command
This function calls SCCI server modules
:param host: hostname or IP of iRMC
:param userid: userid for iRMC with administrator privileges
:param password: password for userid
:param cmd: SCCI command
:param port: port number of iRMC
:param auth_method: irmc_username
... | Explain what the following Python 3 code does
def scci_cmd(host, userid, password, cmd, port=443, auth_method='basic',
client_timeout=60, do_async=True, **kwargs):
"""execute SCCI command
This function calls SCCI server modules
:param host: hostname or IP of iRMC
:param userid: userid for ... | As a Python code analyst, you investigate and solve complex coding mysteries |
get SCCI command partial function | Can you generate a brief explanation for the following Python 3 code
def get_client(host, userid, password, port=443, auth_method='basic',
client_timeout=60, **kwargs):
"""get SCCI command partial function
This function returns SCCI command partial function
:param host: hostname or IP of iRM... | You are a Python code analyst, evaluating scripts for potential improvements. |
get Virtual CD Media Set Parameters Command | How would you explain what the following Python 3 function does
def get_virtual_cd_set_params_cmd(remote_image_server,
remote_image_user_domain,
remote_image_share_type,
remote_image_share_name,
... | As a Python code composer, you craft elegant and concise scripts. |
def get_virtual_fd_set_params_cmd(remote_image_server,
remote_image_user_domain,
remote_image_share_type,
remote_image_share_name,
remote_image_floppy_fat,
... | Write a Python 3 function that can
get Virtual FD Media Set Parameters Command | As a Python code composer, you craft elegant and concise scripts. |
get iRMC report in XML format | Explain what the following Python 3 code does
def get_report(host, userid, password,
port=443, auth_method='basic', client_timeout=60):
"""get iRMC report
This function returns iRMC report in XML format
:param host: hostname or IP of iRMC
:param userid: userid for iRMC with administrator... | You are a Python code architect, reviewing and designing scalable and efficient code |
def get_essential_properties(report, prop_keys):
"""get essential properties
This function returns a dictionary which contains keys as in
prop_keys and its values from the report.
:param report: SCCI report element
:param prop_keys: a list of keys for essential properties
:returns: a dictionar... | How would you implement a function in Python 3 that
gets essential properties from the report element | As a python code expert, you are capable of creating scripts from specifications. |
get capabilities properties
This function returns a dictionary which contains keys
and their values from the report.
:param d_info: the dictionary of ipmitool parameters for accessing a node.
:param capa_keys: a list of keys for additional capabilities properties.
:param gpu_ids: the list of stri... | Can you tell what is the following Python 3 function doing
def get_capabilities_properties(d_info,
capa_keys,
gpu_ids,
fpga_ids=None,
**kwargs):
"""get capabilities properties
This fu... | You are a Python code architect, reviewing and designing scalable and efficient code |
process session status for Bios config backup or restore or RAID config operation | Can you generate a brief explanation for the following Python 3 code
def process_session_status(irmc_info, session_timeout, upgrade_type):
session_expiration = time.time() + session_timeout
while time.time() < session_expiration:
try:
# Get session status to check
session = get_... | As a Python code composer, you craft elegant and concise scripts. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.