repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1 value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1 value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ejeschke/ginga | ginga/AstroImage.py | AstroImage.set_naxispath | def set_naxispath(self, naxispath):
"""Choose a slice out of multidimensional data.
"""
revnaxis = list(naxispath)
revnaxis.reverse()
# construct slice view and extract it
view = tuple(revnaxis + [slice(None), slice(None)])
data = self.get_mddata()[view]
if len(data.shape) != 2:
raise ImageError(
"naxispath does not lead to a 2D slice: {}".format(naxispath))
self.naxispath = naxispath
self.revnaxis = revnaxis
self.set_data(data) | python | def set_naxispath(self, naxispath):
"""Choose a slice out of multidimensional data.
"""
revnaxis = list(naxispath)
revnaxis.reverse()
# construct slice view and extract it
view = tuple(revnaxis + [slice(None), slice(None)])
data = self.get_mddata()[view]
if len(data.shape) != 2:
raise ImageError(
"naxispath does not lead to a 2D slice: {}".format(naxispath))
self.naxispath = naxispath
self.revnaxis = revnaxis
self.set_data(data) | [
"def",
"set_naxispath",
"(",
"self",
",",
"naxispath",
")",
":",
"revnaxis",
"=",
"list",
"(",
"naxispath",
")",
"revnaxis",
".",
"reverse",
"(",
")",
"# construct slice view and extract it",
"view",
"=",
"tuple",
"(",
"revnaxis",
"+",
"[",
"slice",
"(",
"No... | Choose a slice out of multidimensional data. | [
"Choose",
"a",
"slice",
"out",
"of",
"multidimensional",
"data",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/AstroImage.py#L214-L231 | train | 24,800 |
ejeschke/ginga | ginga/AstroImage.py | AstroImage.get_keyword | def get_keyword(self, kwd, *args):
"""Get an item from the fits header, if any."""
try:
kwds = self.get_header()
return kwds[kwd]
except KeyError:
# return a default if there is one
if len(args) > 0:
return args[0]
raise KeyError(kwd) | python | def get_keyword(self, kwd, *args):
"""Get an item from the fits header, if any."""
try:
kwds = self.get_header()
return kwds[kwd]
except KeyError:
# return a default if there is one
if len(args) > 0:
return args[0]
raise KeyError(kwd) | [
"def",
"get_keyword",
"(",
"self",
",",
"kwd",
",",
"*",
"args",
")",
":",
"try",
":",
"kwds",
"=",
"self",
".",
"get_header",
"(",
")",
"return",
"kwds",
"[",
"kwd",
"]",
"except",
"KeyError",
":",
"# return a default if there is one",
"if",
"len",
"(",... | Get an item from the fits header, if any. | [
"Get",
"an",
"item",
"from",
"the",
"fits",
"header",
"if",
"any",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/AstroImage.py#L276-L285 | train | 24,801 |
ejeschke/ginga | ginga/AstroImage.py | AstroImage.as_nddata | def as_nddata(self, nddata_class=None):
"Return a version of ourself as an astropy.nddata.NDData object"
if nddata_class is None:
from astropy.nddata import NDData
nddata_class = NDData
# transfer header, preserving ordering
ahdr = self.get_header()
header = OrderedDict(ahdr.items())
data = self.get_mddata()
wcs = None
if hasattr(self, 'wcs') and self.wcs is not None:
# for now, assume self.wcs wraps an astropy wcs object
wcs = self.wcs.wcs
ndd = nddata_class(data, wcs=wcs, meta=header)
return ndd | python | def as_nddata(self, nddata_class=None):
"Return a version of ourself as an astropy.nddata.NDData object"
if nddata_class is None:
from astropy.nddata import NDData
nddata_class = NDData
# transfer header, preserving ordering
ahdr = self.get_header()
header = OrderedDict(ahdr.items())
data = self.get_mddata()
wcs = None
if hasattr(self, 'wcs') and self.wcs is not None:
# for now, assume self.wcs wraps an astropy wcs object
wcs = self.wcs.wcs
ndd = nddata_class(data, wcs=wcs, meta=header)
return ndd | [
"def",
"as_nddata",
"(",
"self",
",",
"nddata_class",
"=",
"None",
")",
":",
"if",
"nddata_class",
"is",
"None",
":",
"from",
"astropy",
".",
"nddata",
"import",
"NDData",
"nddata_class",
"=",
"NDData",
"# transfer header, preserving ordering",
"ahdr",
"=",
"sel... | Return a version of ourself as an astropy.nddata.NDData object | [
"Return",
"a",
"version",
"of",
"ourself",
"as",
"an",
"astropy",
".",
"nddata",
".",
"NDData",
"object"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/AstroImage.py#L347-L364 | train | 24,802 |
ejeschke/ginga | ginga/AstroImage.py | AstroImage.as_hdu | def as_hdu(self):
"Return a version of ourself as an astropy.io.fits.PrimaryHDU object"
from astropy.io import fits
# transfer header, preserving ordering
ahdr = self.get_header()
header = fits.Header(ahdr.items())
data = self.get_mddata()
hdu = fits.PrimaryHDU(data=data, header=header)
return hdu | python | def as_hdu(self):
"Return a version of ourself as an astropy.io.fits.PrimaryHDU object"
from astropy.io import fits
# transfer header, preserving ordering
ahdr = self.get_header()
header = fits.Header(ahdr.items())
data = self.get_mddata()
hdu = fits.PrimaryHDU(data=data, header=header)
return hdu | [
"def",
"as_hdu",
"(",
"self",
")",
":",
"from",
"astropy",
".",
"io",
"import",
"fits",
"# transfer header, preserving ordering",
"ahdr",
"=",
"self",
".",
"get_header",
"(",
")",
"header",
"=",
"fits",
".",
"Header",
"(",
"ahdr",
".",
"items",
"(",
")",
... | Return a version of ourself as an astropy.io.fits.PrimaryHDU object | [
"Return",
"a",
"version",
"of",
"ourself",
"as",
"an",
"astropy",
".",
"io",
".",
"fits",
".",
"PrimaryHDU",
"object"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/AstroImage.py#L366-L376 | train | 24,803 |
ejeschke/ginga | ginga/AstroImage.py | AstroImage.astype | def astype(self, type_name):
"""Convert AstroImage object to some other kind of object.
"""
if type_name == 'nddata':
return self.as_nddata()
if type_name == 'hdu':
return self.as_hdu()
raise ValueError("Unrecognized conversion type '%s'" % (type_name)) | python | def astype(self, type_name):
"""Convert AstroImage object to some other kind of object.
"""
if type_name == 'nddata':
return self.as_nddata()
if type_name == 'hdu':
return self.as_hdu()
raise ValueError("Unrecognized conversion type '%s'" % (type_name)) | [
"def",
"astype",
"(",
"self",
",",
"type_name",
")",
":",
"if",
"type_name",
"==",
"'nddata'",
":",
"return",
"self",
".",
"as_nddata",
"(",
")",
"if",
"type_name",
"==",
"'hdu'",
":",
"return",
"self",
".",
"as_hdu",
"(",
")",
"raise",
"ValueError",
"... | Convert AstroImage object to some other kind of object. | [
"Convert",
"AstroImage",
"object",
"to",
"some",
"other",
"kind",
"of",
"object",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/AstroImage.py#L378-L387 | train | 24,804 |
ejeschke/ginga | ginga/util/wcs.py | hmsToDeg | def hmsToDeg(h, m, s):
"""Convert RA hours, minutes, seconds into an angle in degrees."""
return h * degPerHMSHour + m * degPerHMSMin + s * degPerHMSSec | python | def hmsToDeg(h, m, s):
"""Convert RA hours, minutes, seconds into an angle in degrees."""
return h * degPerHMSHour + m * degPerHMSMin + s * degPerHMSSec | [
"def",
"hmsToDeg",
"(",
"h",
",",
"m",
",",
"s",
")",
":",
"return",
"h",
"*",
"degPerHMSHour",
"+",
"m",
"*",
"degPerHMSMin",
"+",
"s",
"*",
"degPerHMSSec"
] | Convert RA hours, minutes, seconds into an angle in degrees. | [
"Convert",
"RA",
"hours",
"minutes",
"seconds",
"into",
"an",
"angle",
"in",
"degrees",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L41-L43 | train | 24,805 |
ejeschke/ginga | ginga/util/wcs.py | hmsStrToDeg | def hmsStrToDeg(ra):
"""Convert a string representation of RA into a float in degrees."""
hour, min, sec = ra.split(':')
ra_deg = hmsToDeg(int(hour), int(min), float(sec))
return ra_deg | python | def hmsStrToDeg(ra):
"""Convert a string representation of RA into a float in degrees."""
hour, min, sec = ra.split(':')
ra_deg = hmsToDeg(int(hour), int(min), float(sec))
return ra_deg | [
"def",
"hmsStrToDeg",
"(",
"ra",
")",
":",
"hour",
",",
"min",
",",
"sec",
"=",
"ra",
".",
"split",
"(",
"':'",
")",
"ra_deg",
"=",
"hmsToDeg",
"(",
"int",
"(",
"hour",
")",
",",
"int",
"(",
"min",
")",
",",
"float",
"(",
"sec",
")",
")",
"re... | Convert a string representation of RA into a float in degrees. | [
"Convert",
"a",
"string",
"representation",
"of",
"RA",
"into",
"a",
"float",
"in",
"degrees",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L108-L112 | train | 24,806 |
ejeschke/ginga | ginga/util/wcs.py | dmsStrToDeg | def dmsStrToDeg(dec):
"""Convert a string representation of DEC into a float in degrees."""
sign_deg, min, sec = dec.split(':')
sign = sign_deg[0:1]
if sign not in ('+', '-'):
sign = '+'
deg = sign_deg
else:
deg = sign_deg[1:]
dec_deg = decTimeToDeg(sign, int(deg), int(min), float(sec))
return dec_deg | python | def dmsStrToDeg(dec):
"""Convert a string representation of DEC into a float in degrees."""
sign_deg, min, sec = dec.split(':')
sign = sign_deg[0:1]
if sign not in ('+', '-'):
sign = '+'
deg = sign_deg
else:
deg = sign_deg[1:]
dec_deg = decTimeToDeg(sign, int(deg), int(min), float(sec))
return dec_deg | [
"def",
"dmsStrToDeg",
"(",
"dec",
")",
":",
"sign_deg",
",",
"min",
",",
"sec",
"=",
"dec",
".",
"split",
"(",
"':'",
")",
"sign",
"=",
"sign_deg",
"[",
"0",
":",
"1",
"]",
"if",
"sign",
"not",
"in",
"(",
"'+'",
",",
"'-'",
")",
":",
"sign",
... | Convert a string representation of DEC into a float in degrees. | [
"Convert",
"a",
"string",
"representation",
"of",
"DEC",
"into",
"a",
"float",
"in",
"degrees",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L115-L125 | train | 24,807 |
ejeschke/ginga | ginga/util/wcs.py | eqToEq2000 | def eqToEq2000(ra_deg, dec_deg, eq):
"""Convert Eq to Eq 2000."""
ra_rad = math.radians(ra_deg)
dec_rad = math.radians(dec_deg)
x = math.cos(dec_rad) * math.cos(ra_rad)
y = math.cos(dec_rad) * math.sin(ra_rad)
z = math.sin(dec_rad)
p11, p12, p13, p21, p22, p23, p31, p32, p33 = trans_coeff(eq, x, y, z)
x0 = p11 * x + p21 * y + p31 * z
y0 = p12 * x + p22 * y + p32 * z
z0 = p13 * x + p23 * y + p33 * z
new_dec = math.asin(z0)
if x0 == 0.0:
new_ra = math.pi / 2.0
else:
new_ra = math.atan(y0 / x0)
if ((y0 * math.cos(new_dec) > 0.0 and x0 * math.cos(new_dec) <= 0.0) or
(y0 * math.cos(new_dec) <= 0.0 and x0 * math.cos(new_dec) < 0.0)):
new_ra += math.pi
elif new_ra < 0.0:
new_ra += 2.0 * math.pi
#new_ra = new_ra * 12.0 * 3600.0 / math.pi
new_ra_deg = new_ra * 12.0 / math.pi * 15.0
#new_dec = new_dec * 180.0 * 3600.0 / math.pi
new_dec_deg = new_dec * 180.0 / math.pi
return (new_ra_deg, new_dec_deg) | python | def eqToEq2000(ra_deg, dec_deg, eq):
"""Convert Eq to Eq 2000."""
ra_rad = math.radians(ra_deg)
dec_rad = math.radians(dec_deg)
x = math.cos(dec_rad) * math.cos(ra_rad)
y = math.cos(dec_rad) * math.sin(ra_rad)
z = math.sin(dec_rad)
p11, p12, p13, p21, p22, p23, p31, p32, p33 = trans_coeff(eq, x, y, z)
x0 = p11 * x + p21 * y + p31 * z
y0 = p12 * x + p22 * y + p32 * z
z0 = p13 * x + p23 * y + p33 * z
new_dec = math.asin(z0)
if x0 == 0.0:
new_ra = math.pi / 2.0
else:
new_ra = math.atan(y0 / x0)
if ((y0 * math.cos(new_dec) > 0.0 and x0 * math.cos(new_dec) <= 0.0) or
(y0 * math.cos(new_dec) <= 0.0 and x0 * math.cos(new_dec) < 0.0)):
new_ra += math.pi
elif new_ra < 0.0:
new_ra += 2.0 * math.pi
#new_ra = new_ra * 12.0 * 3600.0 / math.pi
new_ra_deg = new_ra * 12.0 / math.pi * 15.0
#new_dec = new_dec * 180.0 * 3600.0 / math.pi
new_dec_deg = new_dec * 180.0 / math.pi
return (new_ra_deg, new_dec_deg) | [
"def",
"eqToEq2000",
"(",
"ra_deg",
",",
"dec_deg",
",",
"eq",
")",
":",
"ra_rad",
"=",
"math",
".",
"radians",
"(",
"ra_deg",
")",
"dec_rad",
"=",
"math",
".",
"radians",
"(",
"dec_deg",
")",
"x",
"=",
"math",
".",
"cos",
"(",
"dec_rad",
")",
"*",... | Convert Eq to Eq 2000. | [
"Convert",
"Eq",
"to",
"Eq",
"2000",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L175-L209 | train | 24,808 |
ejeschke/ginga | ginga/util/wcs.py | get_rotation_and_scale | def get_rotation_and_scale(header, skew_threshold=0.001):
"""Calculate rotation and CDELT."""
((xrot, yrot),
(cdelt1, cdelt2)) = get_xy_rotation_and_scale(header)
if math.fabs(xrot) - math.fabs(yrot) > skew_threshold:
raise ValueError("Skew detected: xrot=%.4f yrot=%.4f" % (
xrot, yrot))
rot = yrot
lonpole = float(header.get('LONPOLE', 180.0))
if lonpole != 180.0:
rot += 180.0 - lonpole
return (rot, cdelt1, cdelt2) | python | def get_rotation_and_scale(header, skew_threshold=0.001):
"""Calculate rotation and CDELT."""
((xrot, yrot),
(cdelt1, cdelt2)) = get_xy_rotation_and_scale(header)
if math.fabs(xrot) - math.fabs(yrot) > skew_threshold:
raise ValueError("Skew detected: xrot=%.4f yrot=%.4f" % (
xrot, yrot))
rot = yrot
lonpole = float(header.get('LONPOLE', 180.0))
if lonpole != 180.0:
rot += 180.0 - lonpole
return (rot, cdelt1, cdelt2) | [
"def",
"get_rotation_and_scale",
"(",
"header",
",",
"skew_threshold",
"=",
"0.001",
")",
":",
"(",
"(",
"xrot",
",",
"yrot",
")",
",",
"(",
"cdelt1",
",",
"cdelt2",
")",
")",
"=",
"get_xy_rotation_and_scale",
"(",
"header",
")",
"if",
"math",
".",
"fabs... | Calculate rotation and CDELT. | [
"Calculate",
"rotation",
"and",
"CDELT",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L304-L318 | train | 24,809 |
ejeschke/ginga | ginga/util/wcs.py | get_relative_orientation | def get_relative_orientation(image, ref_image):
"""Computes the relative orientation and scale of an image to a reference
image.
Parameters
----------
image
AstroImage based object
ref_image
AstroImage based object
Returns
-------
result
Bunch object containing the relative scale in x and y
and the relative rotation in degrees.
"""
# Get reference image rotation and scale
header = ref_image.get_header()
((xrot_ref, yrot_ref),
(cdelt1_ref, cdelt2_ref)) = get_xy_rotation_and_scale(header)
scale_x, scale_y = math.fabs(cdelt1_ref), math.fabs(cdelt2_ref)
# Get rotation and scale of image
header = image.get_header()
((xrot, yrot),
(cdelt1, cdelt2)) = get_xy_rotation_and_scale(header)
# Determine relative scale of this image to the reference
rscale_x = math.fabs(cdelt1) / scale_x
rscale_y = math.fabs(cdelt2) / scale_y
# Figure out rotation relative to our orientation
rrot_dx, rrot_dy = xrot - xrot_ref, yrot - yrot_ref
# flip_x = False
# flip_y = False
# ## # Flip X due to negative CDELT1
# ## if np.sign(cdelt1) < 0:
# ## flip_x = True
# ## # Flip Y due to negative CDELT2
# ## if np.sign(cdelt2) < 0:
# ## flip_y = True
# # Optomization for 180 rotations
# if np.isclose(math.fabs(rrot_dx), 180.0):
# flip_x = not flip_x
# rrot_dx = 0.0
# if np.isclose(math.fabs(rrot_dy), 180.0):
# flip_y = not flip_y
# rrot_dy = 0.0
rrot_deg = max(rrot_dx, rrot_dy)
res = Bunch.Bunch(rscale_x=rscale_x, rscale_y=rscale_y,
rrot_deg=rrot_deg)
return res | python | def get_relative_orientation(image, ref_image):
"""Computes the relative orientation and scale of an image to a reference
image.
Parameters
----------
image
AstroImage based object
ref_image
AstroImage based object
Returns
-------
result
Bunch object containing the relative scale in x and y
and the relative rotation in degrees.
"""
# Get reference image rotation and scale
header = ref_image.get_header()
((xrot_ref, yrot_ref),
(cdelt1_ref, cdelt2_ref)) = get_xy_rotation_and_scale(header)
scale_x, scale_y = math.fabs(cdelt1_ref), math.fabs(cdelt2_ref)
# Get rotation and scale of image
header = image.get_header()
((xrot, yrot),
(cdelt1, cdelt2)) = get_xy_rotation_and_scale(header)
# Determine relative scale of this image to the reference
rscale_x = math.fabs(cdelt1) / scale_x
rscale_y = math.fabs(cdelt2) / scale_y
# Figure out rotation relative to our orientation
rrot_dx, rrot_dy = xrot - xrot_ref, yrot - yrot_ref
# flip_x = False
# flip_y = False
# ## # Flip X due to negative CDELT1
# ## if np.sign(cdelt1) < 0:
# ## flip_x = True
# ## # Flip Y due to negative CDELT2
# ## if np.sign(cdelt2) < 0:
# ## flip_y = True
# # Optomization for 180 rotations
# if np.isclose(math.fabs(rrot_dx), 180.0):
# flip_x = not flip_x
# rrot_dx = 0.0
# if np.isclose(math.fabs(rrot_dy), 180.0):
# flip_y = not flip_y
# rrot_dy = 0.0
rrot_deg = max(rrot_dx, rrot_dy)
res = Bunch.Bunch(rscale_x=rscale_x, rscale_y=rscale_y,
rrot_deg=rrot_deg)
return res | [
"def",
"get_relative_orientation",
"(",
"image",
",",
"ref_image",
")",
":",
"# Get reference image rotation and scale",
"header",
"=",
"ref_image",
".",
"get_header",
"(",
")",
"(",
"(",
"xrot_ref",
",",
"yrot_ref",
")",
",",
"(",
"cdelt1_ref",
",",
"cdelt2_ref",... | Computes the relative orientation and scale of an image to a reference
image.
Parameters
----------
image
AstroImage based object
ref_image
AstroImage based object
Returns
-------
result
Bunch object containing the relative scale in x and y
and the relative rotation in degrees. | [
"Computes",
"the",
"relative",
"orientation",
"and",
"scale",
"of",
"an",
"image",
"to",
"a",
"reference",
"image",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L321-L382 | train | 24,810 |
ejeschke/ginga | ginga/util/wcs.py | deg2fmt | def deg2fmt(ra_deg, dec_deg, format):
"""Format coordinates."""
rhr, rmn, rsec = degToHms(ra_deg)
dsgn, ddeg, dmn, dsec = degToDms(dec_deg)
if format == 'hms':
return rhr, rmn, rsec, dsgn, ddeg, dmn, dsec
elif format == 'str':
#ra_txt = '%02d:%02d:%06.3f' % (rhr, rmn, rsec)
ra_txt = '%d:%02d:%06.3f' % (rhr, rmn, rsec)
if dsgn < 0:
dsgn = '-'
else:
dsgn = '+'
#dec_txt = '%s%02d:%02d:%05.2f' % (dsgn, ddeg, dmn, dsec)
dec_txt = '%s%d:%02d:%05.2f' % (dsgn, ddeg, dmn, dsec)
return ra_txt, dec_txt | python | def deg2fmt(ra_deg, dec_deg, format):
"""Format coordinates."""
rhr, rmn, rsec = degToHms(ra_deg)
dsgn, ddeg, dmn, dsec = degToDms(dec_deg)
if format == 'hms':
return rhr, rmn, rsec, dsgn, ddeg, dmn, dsec
elif format == 'str':
#ra_txt = '%02d:%02d:%06.3f' % (rhr, rmn, rsec)
ra_txt = '%d:%02d:%06.3f' % (rhr, rmn, rsec)
if dsgn < 0:
dsgn = '-'
else:
dsgn = '+'
#dec_txt = '%s%02d:%02d:%05.2f' % (dsgn, ddeg, dmn, dsec)
dec_txt = '%s%d:%02d:%05.2f' % (dsgn, ddeg, dmn, dsec)
return ra_txt, dec_txt | [
"def",
"deg2fmt",
"(",
"ra_deg",
",",
"dec_deg",
",",
"format",
")",
":",
"rhr",
",",
"rmn",
",",
"rsec",
"=",
"degToHms",
"(",
"ra_deg",
")",
"dsgn",
",",
"ddeg",
",",
"dmn",
",",
"dsec",
"=",
"degToDms",
"(",
"dec_deg",
")",
"if",
"format",
"==",... | Format coordinates. | [
"Format",
"coordinates",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L465-L483 | train | 24,811 |
ejeschke/ginga | ginga/util/wcs.py | deltaStarsRaDecDeg1 | def deltaStarsRaDecDeg1(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Spherical triangulation."""
phi, dist = dispos(ra1_deg, dec1_deg, ra2_deg, dec2_deg)
return arcsecToDeg(dist * 60.0) | python | def deltaStarsRaDecDeg1(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Spherical triangulation."""
phi, dist = dispos(ra1_deg, dec1_deg, ra2_deg, dec2_deg)
return arcsecToDeg(dist * 60.0) | [
"def",
"deltaStarsRaDecDeg1",
"(",
"ra1_deg",
",",
"dec1_deg",
",",
"ra2_deg",
",",
"dec2_deg",
")",
":",
"phi",
",",
"dist",
"=",
"dispos",
"(",
"ra1_deg",
",",
"dec1_deg",
",",
"ra2_deg",
",",
"dec2_deg",
")",
"return",
"arcsecToDeg",
"(",
"dist",
"*",
... | Spherical triangulation. | [
"Spherical",
"triangulation",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L553-L556 | train | 24,812 |
ejeschke/ginga | ginga/util/wcs.py | get_starsep_RaDecDeg | def get_starsep_RaDecDeg(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Calculate separation."""
sep = deltaStarsRaDecDeg(ra1_deg, dec1_deg, ra2_deg, dec2_deg)
sgn, deg, mn, sec = degToDms(sep)
if deg != 0:
txt = '%02d:%02d:%06.3f' % (deg, mn, sec)
else:
txt = '%02d:%06.3f' % (mn, sec)
return txt | python | def get_starsep_RaDecDeg(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Calculate separation."""
sep = deltaStarsRaDecDeg(ra1_deg, dec1_deg, ra2_deg, dec2_deg)
sgn, deg, mn, sec = degToDms(sep)
if deg != 0:
txt = '%02d:%02d:%06.3f' % (deg, mn, sec)
else:
txt = '%02d:%06.3f' % (mn, sec)
return txt | [
"def",
"get_starsep_RaDecDeg",
"(",
"ra1_deg",
",",
"dec1_deg",
",",
"ra2_deg",
",",
"dec2_deg",
")",
":",
"sep",
"=",
"deltaStarsRaDecDeg",
"(",
"ra1_deg",
",",
"dec1_deg",
",",
"ra2_deg",
",",
"dec2_deg",
")",
"sgn",
",",
"deg",
",",
"mn",
",",
"sec",
... | Calculate separation. | [
"Calculate",
"separation",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L577-L585 | train | 24,813 |
ejeschke/ginga | ginga/util/wcs.py | get_RaDecOffsets | def get_RaDecOffsets(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Calculate offset."""
delta_ra_deg = ra1_deg - ra2_deg
adj = math.cos(math.radians(dec2_deg))
if delta_ra_deg > 180.0:
delta_ra_deg = (delta_ra_deg - 360.0) * adj
elif delta_ra_deg < -180.0:
delta_ra_deg = (delta_ra_deg + 360.0) * adj
else:
delta_ra_deg *= adj
delta_dec_deg = dec1_deg - dec2_deg
return (delta_ra_deg, delta_dec_deg) | python | def get_RaDecOffsets(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Calculate offset."""
delta_ra_deg = ra1_deg - ra2_deg
adj = math.cos(math.radians(dec2_deg))
if delta_ra_deg > 180.0:
delta_ra_deg = (delta_ra_deg - 360.0) * adj
elif delta_ra_deg < -180.0:
delta_ra_deg = (delta_ra_deg + 360.0) * adj
else:
delta_ra_deg *= adj
delta_dec_deg = dec1_deg - dec2_deg
return (delta_ra_deg, delta_dec_deg) | [
"def",
"get_RaDecOffsets",
"(",
"ra1_deg",
",",
"dec1_deg",
",",
"ra2_deg",
",",
"dec2_deg",
")",
":",
"delta_ra_deg",
"=",
"ra1_deg",
"-",
"ra2_deg",
"adj",
"=",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"dec2_deg",
")",
")",
"if",
"delta_ra... | Calculate offset. | [
"Calculate",
"offset",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L619-L631 | train | 24,814 |
ejeschke/ginga | ginga/util/wcs.py | lon_to_deg | def lon_to_deg(lon):
"""Convert longitude to degrees."""
if isinstance(lon, str) and (':' in lon):
# TODO: handle other coordinate systems
lon_deg = hmsStrToDeg(lon)
else:
lon_deg = float(lon)
return lon_deg | python | def lon_to_deg(lon):
"""Convert longitude to degrees."""
if isinstance(lon, str) and (':' in lon):
# TODO: handle other coordinate systems
lon_deg = hmsStrToDeg(lon)
else:
lon_deg = float(lon)
return lon_deg | [
"def",
"lon_to_deg",
"(",
"lon",
")",
":",
"if",
"isinstance",
"(",
"lon",
",",
"str",
")",
"and",
"(",
"':'",
"in",
"lon",
")",
":",
"# TODO: handle other coordinate systems",
"lon_deg",
"=",
"hmsStrToDeg",
"(",
"lon",
")",
"else",
":",
"lon_deg",
"=",
... | Convert longitude to degrees. | [
"Convert",
"longitude",
"to",
"degrees",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L646-L653 | train | 24,815 |
ejeschke/ginga | ginga/util/wcs.py | lat_to_deg | def lat_to_deg(lat):
"""Convert latitude to degrees."""
if isinstance(lat, str) and (':' in lat):
# TODO: handle other coordinate systems
lat_deg = dmsStrToDeg(lat)
else:
lat_deg = float(lat)
return lat_deg | python | def lat_to_deg(lat):
"""Convert latitude to degrees."""
if isinstance(lat, str) and (':' in lat):
# TODO: handle other coordinate systems
lat_deg = dmsStrToDeg(lat)
else:
lat_deg = float(lat)
return lat_deg | [
"def",
"lat_to_deg",
"(",
"lat",
")",
":",
"if",
"isinstance",
"(",
"lat",
",",
"str",
")",
"and",
"(",
"':'",
"in",
"lat",
")",
":",
"# TODO: handle other coordinate systems",
"lat_deg",
"=",
"dmsStrToDeg",
"(",
"lat",
")",
"else",
":",
"lat_deg",
"=",
... | Convert latitude to degrees. | [
"Convert",
"latitude",
"to",
"degrees",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L656-L663 | train | 24,816 |
ejeschke/ginga | ginga/util/wcs.py | get_ruler_distances | def get_ruler_distances(image, p1, p2):
"""Get the distance calculated between two points. A Bunch of
results is returned, containing pixel values and distance values
if the image contains a valid WCS.
"""
x1, y1 = p1[:2]
x2, y2 = p2[:2]
dx, dy = x2 - x1, y2 - y1
res = Bunch.Bunch(x1=x1, y1=y1, x2=x2, y2=y2,
theta=np.arctan2(y2 - y1, x2 - x1),
dx_pix=dx, dy_pix=dy,
dh_pix=np.sqrt(dx**2 + dy**2),
ra_org=None, dec_org=None,
ra_dst=None, dec_dst=None,
ra_heel=None, dec_heel=None,
dx_deg=None, dy_deg=None, dh_deg=None)
if image is not None and hasattr(image, 'wcs') and image.wcs is not None:
# Calculate RA and DEC for the three points
try:
# origination point
ra_org, dec_org = image.pixtoradec(x1, y1)
res.ra_org, res.dec_org = ra_org, dec_org
# destination point
ra_dst, dec_dst = image.pixtoradec(x2, y2)
res.ra_dst, res.dec_dst = ra_dst, dec_dst
# "heel" point making a right triangle
ra_heel, dec_heel = image.pixtoradec(x2, y1)
res.ra_heel, res.dec_heel = ra_heel, dec_heel
res.dh_deg = deltaStarsRaDecDeg(ra_org, dec_org,
ra_dst, dec_dst)
res.dx_deg = deltaStarsRaDecDeg(ra_org, dec_org,
ra_heel, dec_heel)
res.dy_deg = deltaStarsRaDecDeg(ra_heel, dec_heel,
ra_dst, dec_dst)
except Exception as e:
pass
return res | python | def get_ruler_distances(image, p1, p2):
"""Get the distance calculated between two points. A Bunch of
results is returned, containing pixel values and distance values
if the image contains a valid WCS.
"""
x1, y1 = p1[:2]
x2, y2 = p2[:2]
dx, dy = x2 - x1, y2 - y1
res = Bunch.Bunch(x1=x1, y1=y1, x2=x2, y2=y2,
theta=np.arctan2(y2 - y1, x2 - x1),
dx_pix=dx, dy_pix=dy,
dh_pix=np.sqrt(dx**2 + dy**2),
ra_org=None, dec_org=None,
ra_dst=None, dec_dst=None,
ra_heel=None, dec_heel=None,
dx_deg=None, dy_deg=None, dh_deg=None)
if image is not None and hasattr(image, 'wcs') and image.wcs is not None:
# Calculate RA and DEC for the three points
try:
# origination point
ra_org, dec_org = image.pixtoradec(x1, y1)
res.ra_org, res.dec_org = ra_org, dec_org
# destination point
ra_dst, dec_dst = image.pixtoradec(x2, y2)
res.ra_dst, res.dec_dst = ra_dst, dec_dst
# "heel" point making a right triangle
ra_heel, dec_heel = image.pixtoradec(x2, y1)
res.ra_heel, res.dec_heel = ra_heel, dec_heel
res.dh_deg = deltaStarsRaDecDeg(ra_org, dec_org,
ra_dst, dec_dst)
res.dx_deg = deltaStarsRaDecDeg(ra_org, dec_org,
ra_heel, dec_heel)
res.dy_deg = deltaStarsRaDecDeg(ra_heel, dec_heel,
ra_dst, dec_dst)
except Exception as e:
pass
return res | [
"def",
"get_ruler_distances",
"(",
"image",
",",
"p1",
",",
"p2",
")",
":",
"x1",
",",
"y1",
"=",
"p1",
"[",
":",
"2",
"]",
"x2",
",",
"y2",
"=",
"p2",
"[",
":",
"2",
"]",
"dx",
",",
"dy",
"=",
"x2",
"-",
"x1",
",",
"y2",
"-",
"y1",
"res"... | Get the distance calculated between two points. A Bunch of
results is returned, containing pixel values and distance values
if the image contains a valid WCS. | [
"Get",
"the",
"distance",
"calculated",
"between",
"two",
"points",
".",
"A",
"Bunch",
"of",
"results",
"is",
"returned",
"containing",
"pixel",
"values",
"and",
"distance",
"values",
"if",
"the",
"image",
"contains",
"a",
"valid",
"WCS",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L666-L708 | train | 24,817 |
ejeschke/ginga | ginga/fonts/font_asst.py | add_font | def add_font(font_file, font_name=None):
"""Add a font description to our directory of externally loadable fonts.
`font_file` is the path to the font, and optional `font_name` is the
name to register it under.
"""
global font_dir
if font_name is None:
# determine family name from filename of font
dirname, filename = os.path.split(font_file)
font_name, ext = os.path.splitext(filename)
font_dir[font_name] = Bunch.Bunch(name=font_name, font_path=font_file)
return font_name | python | def add_font(font_file, font_name=None):
"""Add a font description to our directory of externally loadable fonts.
`font_file` is the path to the font, and optional `font_name` is the
name to register it under.
"""
global font_dir
if font_name is None:
# determine family name from filename of font
dirname, filename = os.path.split(font_file)
font_name, ext = os.path.splitext(filename)
font_dir[font_name] = Bunch.Bunch(name=font_name, font_path=font_file)
return font_name | [
"def",
"add_font",
"(",
"font_file",
",",
"font_name",
"=",
"None",
")",
":",
"global",
"font_dir",
"if",
"font_name",
"is",
"None",
":",
"# determine family name from filename of font",
"dirname",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"f... | Add a font description to our directory of externally loadable fonts.
`font_file` is the path to the font, and optional `font_name` is the
name to register it under. | [
"Add",
"a",
"font",
"description",
"to",
"our",
"directory",
"of",
"externally",
"loadable",
"fonts",
".",
"font_file",
"is",
"the",
"path",
"to",
"the",
"font",
"and",
"optional",
"font_name",
"is",
"the",
"name",
"to",
"register",
"it",
"under",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/fonts/font_asst.py#L56-L70 | train | 24,818 |
ejeschke/ginga | ginga/fonts/font_asst.py | have_font | def have_font(font_name):
"""Return True if the given font name is registered as one of our
externally loadable fonts. If `font_name` is not found, it will try
to look it up as an alias and report if that is found.
"""
if font_name in font_dir:
return True
# try it as an alias
font_name = resolve_alias(font_name, font_name)
return font_name in font_dir | python | def have_font(font_name):
"""Return True if the given font name is registered as one of our
externally loadable fonts. If `font_name` is not found, it will try
to look it up as an alias and report if that is found.
"""
if font_name in font_dir:
return True
# try it as an alias
font_name = resolve_alias(font_name, font_name)
return font_name in font_dir | [
"def",
"have_font",
"(",
"font_name",
")",
":",
"if",
"font_name",
"in",
"font_dir",
":",
"return",
"True",
"# try it as an alias",
"font_name",
"=",
"resolve_alias",
"(",
"font_name",
",",
"font_name",
")",
"return",
"font_name",
"in",
"font_dir"
] | Return True if the given font name is registered as one of our
externally loadable fonts. If `font_name` is not found, it will try
to look it up as an alias and report if that is found. | [
"Return",
"True",
"if",
"the",
"given",
"font",
"name",
"is",
"registered",
"as",
"one",
"of",
"our",
"externally",
"loadable",
"fonts",
".",
"If",
"font_name",
"is",
"not",
"found",
"it",
"will",
"try",
"to",
"look",
"it",
"up",
"as",
"an",
"alias",
"... | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/fonts/font_asst.py#L73-L83 | train | 24,819 |
ejeschke/ginga | ginga/rv/plugins/Drawing.py | Drawing.toggle_create_button | def toggle_create_button(self):
"""Enable or disable Create Mask button based on drawn objects."""
if len(self._drawn_tags) > 0:
self.w.create_mask.set_enabled(True)
else:
self.w.create_mask.set_enabled(False) | python | def toggle_create_button(self):
"""Enable or disable Create Mask button based on drawn objects."""
if len(self._drawn_tags) > 0:
self.w.create_mask.set_enabled(True)
else:
self.w.create_mask.set_enabled(False) | [
"def",
"toggle_create_button",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_drawn_tags",
")",
">",
"0",
":",
"self",
".",
"w",
".",
"create_mask",
".",
"set_enabled",
"(",
"True",
")",
"else",
":",
"self",
".",
"w",
".",
"create_mask",
"."... | Enable or disable Create Mask button based on drawn objects. | [
"Enable",
"or",
"disable",
"Create",
"Mask",
"button",
"based",
"on",
"drawn",
"objects",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Drawing.py#L355-L360 | train | 24,820 |
ejeschke/ginga | ginga/rv/plugins/Drawing.py | Drawing.create_mask | def create_mask(self):
"""Create boolean mask from drawing.
All areas enclosed by all the shapes drawn will be set to 1 (True)
in the mask. Otherwise, the values will be set to 0 (False).
The mask will be inserted as a new image buffer, like ``Mosaic``.
"""
ntags = len(self._drawn_tags)
if ntags == 0:
return
old_image = self.fitsimage.get_image()
if old_image is None:
return
mask = None
obj_kinds = set()
# Create mask
for tag in self._drawn_tags:
obj = self.canvas.get_object_by_tag(tag)
try:
cur_mask = old_image.get_shape_mask(obj)
except Exception as e:
self.logger.error('Cannot create mask: {0}'.format(str(e)))
continue
if mask is not None:
mask |= cur_mask
else:
mask = cur_mask
obj_kinds.add(obj.kind)
# Might be useful to inherit header from displayed image (e.g., WCS)
# but the displayed image should not be modified.
# Bool needs to be converted to int so FITS writer would not crash.
image = dp.make_image(mask.astype('int16'), old_image, {},
pfx=self._mask_prefix)
imname = image.get('name')
# Insert new image
self.fv.gui_call(self.fv.add_image, imname, image, chname=self.chname)
# Add description to ChangeHistory
s = 'Mask created from {0} drawings ({1})'.format(
ntags, ','.join(sorted(obj_kinds)))
info = dict(time_modified=datetime.utcnow(), reason_modified=s)
self.fv.update_image_info(image, info)
self.logger.info(s) | python | def create_mask(self):
"""Create boolean mask from drawing.
All areas enclosed by all the shapes drawn will be set to 1 (True)
in the mask. Otherwise, the values will be set to 0 (False).
The mask will be inserted as a new image buffer, like ``Mosaic``.
"""
ntags = len(self._drawn_tags)
if ntags == 0:
return
old_image = self.fitsimage.get_image()
if old_image is None:
return
mask = None
obj_kinds = set()
# Create mask
for tag in self._drawn_tags:
obj = self.canvas.get_object_by_tag(tag)
try:
cur_mask = old_image.get_shape_mask(obj)
except Exception as e:
self.logger.error('Cannot create mask: {0}'.format(str(e)))
continue
if mask is not None:
mask |= cur_mask
else:
mask = cur_mask
obj_kinds.add(obj.kind)
# Might be useful to inherit header from displayed image (e.g., WCS)
# but the displayed image should not be modified.
# Bool needs to be converted to int so FITS writer would not crash.
image = dp.make_image(mask.astype('int16'), old_image, {},
pfx=self._mask_prefix)
imname = image.get('name')
# Insert new image
self.fv.gui_call(self.fv.add_image, imname, image, chname=self.chname)
# Add description to ChangeHistory
s = 'Mask created from {0} drawings ({1})'.format(
ntags, ','.join(sorted(obj_kinds)))
info = dict(time_modified=datetime.utcnow(), reason_modified=s)
self.fv.update_image_info(image, info)
self.logger.info(s) | [
"def",
"create_mask",
"(",
"self",
")",
":",
"ntags",
"=",
"len",
"(",
"self",
".",
"_drawn_tags",
")",
"if",
"ntags",
"==",
"0",
":",
"return",
"old_image",
"=",
"self",
".",
"fitsimage",
".",
"get_image",
"(",
")",
"if",
"old_image",
"is",
"None",
... | Create boolean mask from drawing.
All areas enclosed by all the shapes drawn will be set to 1 (True)
in the mask. Otherwise, the values will be set to 0 (False).
The mask will be inserted as a new image buffer, like ``Mosaic``. | [
"Create",
"boolean",
"mask",
"from",
"drawing",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Drawing.py#L362-L415 | train | 24,821 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_load | def cmd_load(self, *args, **kwargs):
"""load file ... ch=chname
Read files or URLs into the given channel.
If the item is a path and it does not begin with a slash it is assumed
to be relative to the current working directory. File patterns can
also be provided.
"""
ch = kwargs.get('ch', None)
for item in args:
# TODO: check for URI syntax
files = glob.glob(item)
self.fv.gui_do(self.fv.open_uris, files, chname=ch) | python | def cmd_load(self, *args, **kwargs):
"""load file ... ch=chname
Read files or URLs into the given channel.
If the item is a path and it does not begin with a slash it is assumed
to be relative to the current working directory. File patterns can
also be provided.
"""
ch = kwargs.get('ch', None)
for item in args:
# TODO: check for URI syntax
files = glob.glob(item)
self.fv.gui_do(self.fv.open_uris, files, chname=ch) | [
"def",
"cmd_load",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ch",
"=",
"kwargs",
".",
"get",
"(",
"'ch'",
",",
"None",
")",
"for",
"item",
"in",
"args",
":",
"# TODO: check for URI syntax",
"files",
"=",
"glob",
".",
"glob",
... | load file ... ch=chname
Read files or URLs into the given channel.
If the item is a path and it does not begin with a slash it is assumed
to be relative to the current working directory. File patterns can
also be provided. | [
"load",
"file",
"...",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L280-L294 | train | 24,822 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_cuts | def cmd_cuts(self, lo=None, hi=None, ch=None):
"""cuts lo=val hi=val ch=chname
If neither `lo` nor `hi` is provided, returns the current cut levels.
Otherwise sets the corresponding cut level for the given channel.
If `ch` is omitted, assumes the current channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
loval, hival = viewer.get_cut_levels()
if (lo is None) and (hi is None):
self.log("lo=%f hi=%f" % (loval, hival))
else:
if lo is not None:
loval = lo
if hi is not None:
hival = hi
viewer.cut_levels(loval, hival)
self.log("lo=%f hi=%f" % (loval, hival)) | python | def cmd_cuts(self, lo=None, hi=None, ch=None):
"""cuts lo=val hi=val ch=chname
If neither `lo` nor `hi` is provided, returns the current cut levels.
Otherwise sets the corresponding cut level for the given channel.
If `ch` is omitted, assumes the current channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
loval, hival = viewer.get_cut_levels()
if (lo is None) and (hi is None):
self.log("lo=%f hi=%f" % (loval, hival))
else:
if lo is not None:
loval = lo
if hi is not None:
hival = hi
viewer.cut_levels(loval, hival)
self.log("lo=%f hi=%f" % (loval, hival)) | [
"def",
"cmd_cuts",
"(",
"self",
",",
"lo",
"=",
"None",
",",
"hi",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current ... | cuts lo=val hi=val ch=chname
If neither `lo` nor `hi` is provided, returns the current cut levels.
Otherwise sets the corresponding cut level for the given channel.
If `ch` is omitted, assumes the current channel. | [
"cuts",
"lo",
"=",
"val",
"hi",
"=",
"val",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L296-L320 | train | 24,823 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_ac | def cmd_ac(self, ch=None):
"""ac ch=chname
Calculate and set auto cut levels for the given channel.
If `ch` is omitted, assumes the current channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.auto_levels()
self.cmd_cuts(ch=ch) | python | def cmd_ac(self, ch=None):
"""ac ch=chname
Calculate and set auto cut levels for the given channel.
If `ch` is omitted, assumes the current channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.auto_levels()
self.cmd_cuts(ch=ch) | [
"def",
"cmd_ac",
"(",
"self",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"return",
"viewer",
".",
"auto_... | ac ch=chname
Calculate and set auto cut levels for the given channel.
If `ch` is omitted, assumes the current channel. | [
"ac",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L322-L334 | train | 24,824 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_cm | def cmd_cm(self, nm=None, ch=None):
"""cm nm=color_map_name ch=chname
Set a color map (name `nm`) for the given channel.
If no value is given, reports the current color map.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if nm is None:
rgbmap = viewer.get_rgbmap()
cmap = rgbmap.get_cmap()
self.log(cmap.name)
else:
viewer.set_color_map(nm) | python | def cmd_cm(self, nm=None, ch=None):
"""cm nm=color_map_name ch=chname
Set a color map (name `nm`) for the given channel.
If no value is given, reports the current color map.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if nm is None:
rgbmap = viewer.get_rgbmap()
cmap = rgbmap.get_cmap()
self.log(cmap.name)
else:
viewer.set_color_map(nm) | [
"def",
"cmd_cm",
"(",
"self",
",",
"nm",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"retu... | cm nm=color_map_name ch=chname
Set a color map (name `nm`) for the given channel.
If no value is given, reports the current color map. | [
"cm",
"nm",
"=",
"color_map_name",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L343-L360 | train | 24,825 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_cminv | def cmd_cminv(self, ch=None):
"""cminv ch=chname
Invert the color map in the channel/viewer
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.invert_cmap() | python | def cmd_cminv(self, ch=None):
"""cminv ch=chname
Invert the color map in the channel/viewer
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.invert_cmap() | [
"def",
"cmd_cminv",
"(",
"self",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"return",
"viewer",
".",
"in... | cminv ch=chname
Invert the color map in the channel/viewer | [
"cminv",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L362-L372 | train | 24,826 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_dist | def cmd_dist(self, nm=None, ch=None):
"""dist nm=dist_name ch=chname
Set a color distribution for the given channel.
Possible values are linear, log, power, sqrt, squared, asinh, sinh,
and histeq.
If no value is given, reports the current color distribution
algorithm.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if nm is None:
rgbmap = viewer.get_rgbmap()
dist = rgbmap.get_dist()
self.log(str(dist))
else:
viewer.set_color_algorithm(nm) | python | def cmd_dist(self, nm=None, ch=None):
"""dist nm=dist_name ch=chname
Set a color distribution for the given channel.
Possible values are linear, log, power, sqrt, squared, asinh, sinh,
and histeq.
If no value is given, reports the current color distribution
algorithm.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if nm is None:
rgbmap = viewer.get_rgbmap()
dist = rgbmap.get_dist()
self.log(str(dist))
else:
viewer.set_color_algorithm(nm) | [
"def",
"cmd_dist",
"(",
"self",
",",
"nm",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"re... | dist nm=dist_name ch=chname
Set a color distribution for the given channel.
Possible values are linear, log, power, sqrt, squared, asinh, sinh,
and histeq.
If no value is given, reports the current color distribution
algorithm. | [
"dist",
"nm",
"=",
"dist_name",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L374-L394 | train | 24,827 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_imap | def cmd_imap(self, nm=None, ch=None):
"""imap nm=intensity_map_name ch=chname
Set an intensity map (name `nm`) for the given channel.
If no value is given, reports the current intensity map.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if nm is None:
rgbmap = viewer.get_rgbmap()
imap = rgbmap.get_imap()
self.log(imap.name)
else:
viewer.set_intensity_map(nm) | python | def cmd_imap(self, nm=None, ch=None):
"""imap nm=intensity_map_name ch=chname
Set an intensity map (name `nm`) for the given channel.
If no value is given, reports the current intensity map.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if nm is None:
rgbmap = viewer.get_rgbmap()
imap = rgbmap.get_imap()
self.log(imap.name)
else:
viewer.set_intensity_map(nm) | [
"def",
"cmd_imap",
"(",
"self",
",",
"nm",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"re... | imap nm=intensity_map_name ch=chname
Set an intensity map (name `nm`) for the given channel.
If no value is given, reports the current intensity map. | [
"imap",
"nm",
"=",
"intensity_map_name",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L403-L420 | train | 24,828 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_rot | def cmd_rot(self, deg=None, ch=None):
"""rot deg=num_deg ch=chname
Rotate the image for the given viewer/channel by the given
number of degrees.
If no value is given, reports the current rotation.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if deg is None:
self.log("%f deg" % (viewer.get_rotation()))
else:
viewer.rotate(deg) | python | def cmd_rot(self, deg=None, ch=None):
"""rot deg=num_deg ch=chname
Rotate the image for the given viewer/channel by the given
number of degrees.
If no value is given, reports the current rotation.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
if deg is None:
self.log("%f deg" % (viewer.get_rotation()))
else:
viewer.rotate(deg) | [
"def",
"cmd_rot",
"(",
"self",
",",
"deg",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"re... | rot deg=num_deg ch=chname
Rotate the image for the given viewer/channel by the given
number of degrees.
If no value is given, reports the current rotation. | [
"rot",
"deg",
"=",
"num_deg",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L444-L460 | train | 24,829 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_tr | def cmd_tr(self, x=None, y=None, xy=None, ch=None):
"""tr x=0|1 y=0|1 xy=0|1 ch=chname
Transform the image for the given viewer/channel by flipping
(x=1 and/or y=1) or swapping axes (xy=1).
If no value is given, reports the current rotation.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
fx, fy, sxy = viewer.get_transforms()
if x is None and y is None and xy is None:
self.log("x=%s y=%s xy=%s" % (fx, fy, sxy))
else:
# turn these into True or False
if x is None:
x = fx
else:
x = (x != 0)
if y is None:
y = fy
else:
y = (y != 0)
if xy is None:
xy = sxy
else:
xy = (xy != 0)
viewer.transform(x, y, xy) | python | def cmd_tr(self, x=None, y=None, xy=None, ch=None):
"""tr x=0|1 y=0|1 xy=0|1 ch=chname
Transform the image for the given viewer/channel by flipping
(x=1 and/or y=1) or swapping axes (xy=1).
If no value is given, reports the current rotation.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
fx, fy, sxy = viewer.get_transforms()
if x is None and y is None and xy is None:
self.log("x=%s y=%s xy=%s" % (fx, fy, sxy))
else:
# turn these into True or False
if x is None:
x = fx
else:
x = (x != 0)
if y is None:
y = fy
else:
y = (y != 0)
if xy is None:
xy = sxy
else:
xy = (xy != 0)
viewer.transform(x, y, xy) | [
"def",
"cmd_tr",
"(",
"self",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"xy",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"l... | tr x=0|1 y=0|1 xy=0|1 ch=chname
Transform the image for the given viewer/channel by flipping
(x=1 and/or y=1) or swapping axes (xy=1).
If no value is given, reports the current rotation. | [
"tr",
"x",
"=",
"0|1",
"y",
"=",
"0|1",
"xy",
"=",
"0|1",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L462-L494 | train | 24,830 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_scale | def cmd_scale(self, x=None, y=None, ch=None):
"""scale x=scale_x y=scale_y ch=chname
Scale the image for the given viewer/channel by the given amounts.
If only one scale value is given, the other is assumed to be the
same. If no value is given, reports the current scale.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
scale_x, scale_y = viewer.get_scale_xy()
if x is None and y is None:
self.log("x=%f y=%f" % (scale_x, scale_y))
else:
if x is not None:
if y is None:
y = x
if y is not None:
if x is None:
x = y
viewer.scale_to(x, y) | python | def cmd_scale(self, x=None, y=None, ch=None):
"""scale x=scale_x y=scale_y ch=chname
Scale the image for the given viewer/channel by the given amounts.
If only one scale value is given, the other is assumed to be the
same. If no value is given, reports the current scale.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
scale_x, scale_y = viewer.get_scale_xy()
if x is None and y is None:
self.log("x=%f y=%f" % (scale_x, scale_y))
else:
if x is not None:
if y is None:
y = x
if y is not None:
if x is None:
x = y
viewer.scale_to(x, y) | [
"def",
"cmd_scale",
"(",
"self",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current v... | scale x=scale_x y=scale_y ch=chname
Scale the image for the given viewer/channel by the given amounts.
If only one scale value is given, the other is assumed to be the
same. If no value is given, reports the current scale. | [
"scale",
"x",
"=",
"scale_x",
"y",
"=",
"scale_y",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L496-L520 | train | 24,831 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_z | def cmd_z(self, lvl=None, ch=None):
"""z lvl=level ch=chname
Zoom the image for the given viewer/channel to the given zoom
level. Levels can be positive or negative numbers and are
relative to a scale of 1:1 at zoom level 0.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
cur_lvl = viewer.get_zoom()
if lvl is None:
self.log("zoom=%f" % (cur_lvl))
else:
viewer.zoom_to(lvl) | python | def cmd_z(self, lvl=None, ch=None):
"""z lvl=level ch=chname
Zoom the image for the given viewer/channel to the given zoom
level. Levels can be positive or negative numbers and are
relative to a scale of 1:1 at zoom level 0.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
cur_lvl = viewer.get_zoom()
if lvl is None:
self.log("zoom=%f" % (cur_lvl))
else:
viewer.zoom_to(lvl) | [
"def",
"cmd_z",
"(",
"self",
",",
"lvl",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"retu... | z lvl=level ch=chname
Zoom the image for the given viewer/channel to the given zoom
level. Levels can be positive or negative numbers and are
relative to a scale of 1:1 at zoom level 0. | [
"z",
"lvl",
"=",
"level",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L522-L540 | train | 24,832 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_zf | def cmd_zf(self, ch=None):
"""zf ch=chname
Zoom the image for the given viewer/channel to fit the window.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.zoom_fit()
cur_lvl = viewer.get_zoom()
self.log("zoom=%f" % (cur_lvl)) | python | def cmd_zf(self, ch=None):
"""zf ch=chname
Zoom the image for the given viewer/channel to fit the window.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.zoom_fit()
cur_lvl = viewer.get_zoom()
self.log("zoom=%f" % (cur_lvl)) | [
"def",
"cmd_zf",
"(",
"self",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"return",
"viewer",
".",
"zoom_... | zf ch=chname
Zoom the image for the given viewer/channel to fit the window. | [
"zf",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L542-L554 | train | 24,833 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_c | def cmd_c(self, ch=None):
"""c ch=chname
Center the image for the given viewer/channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.center_image() | python | def cmd_c(self, ch=None):
"""c ch=chname
Center the image for the given viewer/channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.center_image() | [
"def",
"cmd_c",
"(",
"self",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current viewer/channel.\"",
")",
"return",
"viewer",
".",
"center... | c ch=chname
Center the image for the given viewer/channel. | [
"c",
"ch",
"=",
"chname"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L556-L566 | train | 24,834 |
ejeschke/ginga | ginga/rv/plugins/Command.py | CommandInterpreter.cmd_pan | def cmd_pan(self, x=None, y=None, ch=None):
"""scale ch=chname x=pan_x y=pan_y
Set the pan position for the given viewer/channel to the given
pixel coordinates.
If no coordinates are given, reports the current position.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
pan_x, pan_y = viewer.get_pan()
if x is None and y is None:
self.log("x=%f y=%f" % (pan_x, pan_y))
else:
if x is not None:
if y is None:
y = pan_y
if y is not None:
if x is None:
x = pan_x
viewer.set_pan(x, y) | python | def cmd_pan(self, x=None, y=None, ch=None):
"""scale ch=chname x=pan_x y=pan_y
Set the pan position for the given viewer/channel to the given
pixel coordinates.
If no coordinates are given, reports the current position.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
pan_x, pan_y = viewer.get_pan()
if x is None and y is None:
self.log("x=%f y=%f" % (pan_x, pan_y))
else:
if x is not None:
if y is None:
y = pan_y
if y is not None:
if x is None:
x = pan_x
viewer.set_pan(x, y) | [
"def",
"cmd_pan",
"(",
"self",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"ch",
"=",
"None",
")",
":",
"viewer",
"=",
"self",
".",
"get_viewer",
"(",
"ch",
")",
"if",
"viewer",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"No current vie... | scale ch=chname x=pan_x y=pan_y
Set the pan position for the given viewer/channel to the given
pixel coordinates.
If no coordinates are given, reports the current position. | [
"scale",
"ch",
"=",
"chname",
"x",
"=",
"pan_x",
"y",
"=",
"pan_y"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Command.py#L568-L592 | train | 24,835 |
ejeschke/ginga | ginga/util/heaptimer.py | TimerHeap.timer | def timer(self, jitter, action, *args, **kwargs):
"""Convenience method to create a Timer from the heap"""
return Timer(self, jitter, action, *args, **kwargs) | python | def timer(self, jitter, action, *args, **kwargs):
"""Convenience method to create a Timer from the heap"""
return Timer(self, jitter, action, *args, **kwargs) | [
"def",
"timer",
"(",
"self",
",",
"jitter",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Timer",
"(",
"self",
",",
"jitter",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Convenience method to create a Timer from the heap | [
"Convenience",
"method",
"to",
"create",
"a",
"Timer",
"from",
"the",
"heap"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/heaptimer.py#L123-L125 | train | 24,836 |
ejeschke/ginga | ginga/util/heaptimer.py | TimerHeap.add | def add(self, timer):
"""Add a timer to the heap"""
with self.lock:
if self.heap:
top = self.heap[0]
else:
top = None
assert timer not in self.timers
self.timers[timer] = timer
heapq.heappush(self.heap, timer)
# Check to see if we need to reschedule our main timer.
# Only do this if we aren't expiring in the other thread.
if self.heap[0] != top and not self.expiring:
if self.rtimer is not None:
self.rtimer.cancel()
# self.rtimer.join()
self.rtimer = None
# If we are expiring timers right now then that will reschedule
# as appropriate otherwise let's start a timer if we don't have
# one
if self.rtimer is None and not self.expiring:
top = self.heap[0]
ival = top.expire - time.time()
if ival < 0:
ival = 0
self.rtimer = threading.Timer(ival, self.expire)
self.rtimer.start() | python | def add(self, timer):
"""Add a timer to the heap"""
with self.lock:
if self.heap:
top = self.heap[0]
else:
top = None
assert timer not in self.timers
self.timers[timer] = timer
heapq.heappush(self.heap, timer)
# Check to see if we need to reschedule our main timer.
# Only do this if we aren't expiring in the other thread.
if self.heap[0] != top and not self.expiring:
if self.rtimer is not None:
self.rtimer.cancel()
# self.rtimer.join()
self.rtimer = None
# If we are expiring timers right now then that will reschedule
# as appropriate otherwise let's start a timer if we don't have
# one
if self.rtimer is None and not self.expiring:
top = self.heap[0]
ival = top.expire - time.time()
if ival < 0:
ival = 0
self.rtimer = threading.Timer(ival, self.expire)
self.rtimer.start() | [
"def",
"add",
"(",
"self",
",",
"timer",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"heap",
":",
"top",
"=",
"self",
".",
"heap",
"[",
"0",
"]",
"else",
":",
"top",
"=",
"None",
"assert",
"timer",
"not",
"in",
"self",
".",
... | Add a timer to the heap | [
"Add",
"a",
"timer",
"to",
"the",
"heap"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/heaptimer.py#L127-L156 | train | 24,837 |
ejeschke/ginga | ginga/util/heaptimer.py | TimerHeap._remove | def _remove(self, timer):
"""Remove timer from heap lock and presence are assumed"""
assert timer.timer_heap == self
del self.timers[timer]
assert timer in self.heap
self.heap.remove(timer)
heapq.heapify(self.heap) | python | def _remove(self, timer):
"""Remove timer from heap lock and presence are assumed"""
assert timer.timer_heap == self
del self.timers[timer]
assert timer in self.heap
self.heap.remove(timer)
heapq.heapify(self.heap) | [
"def",
"_remove",
"(",
"self",
",",
"timer",
")",
":",
"assert",
"timer",
".",
"timer_heap",
"==",
"self",
"del",
"self",
".",
"timers",
"[",
"timer",
"]",
"assert",
"timer",
"in",
"self",
".",
"heap",
"self",
".",
"heap",
".",
"remove",
"(",
"timer"... | Remove timer from heap lock and presence are assumed | [
"Remove",
"timer",
"from",
"heap",
"lock",
"and",
"presence",
"are",
"assumed"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/heaptimer.py#L201-L207 | train | 24,838 |
ejeschke/ginga | ginga/util/heaptimer.py | TimerHeap.remove | def remove(self, timer):
"""Remove a timer from the heap, return True if already run"""
with self.lock:
# This is somewhat expensive as we have to heapify.
if timer in self.timers:
self._remove(timer)
return False
else:
return True | python | def remove(self, timer):
"""Remove a timer from the heap, return True if already run"""
with self.lock:
# This is somewhat expensive as we have to heapify.
if timer in self.timers:
self._remove(timer)
return False
else:
return True | [
"def",
"remove",
"(",
"self",
",",
"timer",
")",
":",
"with",
"self",
".",
"lock",
":",
"# This is somewhat expensive as we have to heapify.",
"if",
"timer",
"in",
"self",
".",
"timers",
":",
"self",
".",
"_remove",
"(",
"timer",
")",
"return",
"False",
"els... | Remove a timer from the heap, return True if already run | [
"Remove",
"a",
"timer",
"from",
"the",
"heap",
"return",
"True",
"if",
"already",
"run"
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/heaptimer.py#L209-L217 | train | 24,839 |
ejeschke/ginga | ginga/util/heaptimer.py | TimerHeap.remove_all_timers | def remove_all_timers(self):
"""Remove all waiting timers and terminate any blocking threads."""
with self.lock:
if self.rtimer is not None:
self.rtimer.cancel()
self.timers = {}
self.heap = []
self.rtimer = None
self.expiring = False | python | def remove_all_timers(self):
"""Remove all waiting timers and terminate any blocking threads."""
with self.lock:
if self.rtimer is not None:
self.rtimer.cancel()
self.timers = {}
self.heap = []
self.rtimer = None
self.expiring = False | [
"def",
"remove_all_timers",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"rtimer",
"is",
"not",
"None",
":",
"self",
".",
"rtimer",
".",
"cancel",
"(",
")",
"self",
".",
"timers",
"=",
"{",
"}",
"self",
".",
"heap",
... | Remove all waiting timers and terminate any blocking threads. | [
"Remove",
"all",
"waiting",
"timers",
"and",
"terminate",
"any",
"blocking",
"threads",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/heaptimer.py#L219-L228 | train | 24,840 |
ejeschke/ginga | ginga/canvas/CompoundMixin.py | CompoundMixin.get_llur | def get_llur(self):
"""
Get lower-left and upper-right coordinates of the bounding box
of this compound object.
Returns
-------
x1, y1, x2, y2: a 4-tuple of the lower-left and upper-right coords
"""
points = np.array([obj.get_llur() for obj in self.objects])
t_ = points.T
x1, y1 = t_[0].min(), t_[1].min()
x2, y2 = t_[2].max(), t_[3].max()
return (x1, y1, x2, y2) | python | def get_llur(self):
"""
Get lower-left and upper-right coordinates of the bounding box
of this compound object.
Returns
-------
x1, y1, x2, y2: a 4-tuple of the lower-left and upper-right coords
"""
points = np.array([obj.get_llur() for obj in self.objects])
t_ = points.T
x1, y1 = t_[0].min(), t_[1].min()
x2, y2 = t_[2].max(), t_[3].max()
return (x1, y1, x2, y2) | [
"def",
"get_llur",
"(",
"self",
")",
":",
"points",
"=",
"np",
".",
"array",
"(",
"[",
"obj",
".",
"get_llur",
"(",
")",
"for",
"obj",
"in",
"self",
".",
"objects",
"]",
")",
"t_",
"=",
"points",
".",
"T",
"x1",
",",
"y1",
"=",
"t_",
"[",
"0"... | Get lower-left and upper-right coordinates of the bounding box
of this compound object.
Returns
-------
x1, y1, x2, y2: a 4-tuple of the lower-left and upper-right coords | [
"Get",
"lower",
"-",
"left",
"and",
"upper",
"-",
"right",
"coordinates",
"of",
"the",
"bounding",
"box",
"of",
"this",
"compound",
"object",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/canvas/CompoundMixin.py#L36-L49 | train | 24,841 |
ejeschke/ginga | ginga/web/pgw/ipg.py | BasicCanvasView.build_gui | def build_gui(self, container):
"""
This is responsible for building the viewer's UI. It should
place the UI in `container`. Override this to make a custom
UI.
"""
vbox = Widgets.VBox()
vbox.set_border_width(0)
w = Viewers.GingaViewerWidget(viewer=self)
vbox.add_widget(w, stretch=1)
# need to put this in an hbox with an expanding label or the
# browser wants to resize the canvas, distorting it
hbox = Widgets.HBox()
hbox.add_widget(vbox, stretch=0)
hbox.add_widget(Widgets.Label(''), stretch=1)
container.set_widget(hbox) | python | def build_gui(self, container):
"""
This is responsible for building the viewer's UI. It should
place the UI in `container`. Override this to make a custom
UI.
"""
vbox = Widgets.VBox()
vbox.set_border_width(0)
w = Viewers.GingaViewerWidget(viewer=self)
vbox.add_widget(w, stretch=1)
# need to put this in an hbox with an expanding label or the
# browser wants to resize the canvas, distorting it
hbox = Widgets.HBox()
hbox.add_widget(vbox, stretch=0)
hbox.add_widget(Widgets.Label(''), stretch=1)
container.set_widget(hbox) | [
"def",
"build_gui",
"(",
"self",
",",
"container",
")",
":",
"vbox",
"=",
"Widgets",
".",
"VBox",
"(",
")",
"vbox",
".",
"set_border_width",
"(",
"0",
")",
"w",
"=",
"Viewers",
".",
"GingaViewerWidget",
"(",
"viewer",
"=",
"self",
")",
"vbox",
".",
"... | This is responsible for building the viewer's UI. It should
place the UI in `container`. Override this to make a custom
UI. | [
"This",
"is",
"responsible",
"for",
"building",
"the",
"viewer",
"s",
"UI",
".",
"It",
"should",
"place",
"the",
"UI",
"in",
"container",
".",
"Override",
"this",
"to",
"make",
"a",
"custom",
"UI",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L42-L60 | train | 24,842 |
ejeschke/ginga | ginga/web/pgw/ipg.py | BasicCanvasView.embed | def embed(self, width=600, height=650):
"""
Embed a viewer into a Jupyter notebook.
"""
from IPython.display import IFrame
return IFrame(self.url, width, height) | python | def embed(self, width=600, height=650):
"""
Embed a viewer into a Jupyter notebook.
"""
from IPython.display import IFrame
return IFrame(self.url, width, height) | [
"def",
"embed",
"(",
"self",
",",
"width",
"=",
"600",
",",
"height",
"=",
"650",
")",
":",
"from",
"IPython",
".",
"display",
"import",
"IFrame",
"return",
"IFrame",
"(",
"self",
".",
"url",
",",
"width",
",",
"height",
")"
] | Embed a viewer into a Jupyter notebook. | [
"Embed",
"a",
"viewer",
"into",
"a",
"Jupyter",
"notebook",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L62-L67 | train | 24,843 |
ejeschke/ginga | ginga/web/pgw/ipg.py | BasicCanvasView.load_fits | def load_fits(self, filepath):
"""
Load a FITS file into the viewer.
"""
image = AstroImage.AstroImage(logger=self.logger)
image.load_file(filepath)
self.set_image(image) | python | def load_fits(self, filepath):
"""
Load a FITS file into the viewer.
"""
image = AstroImage.AstroImage(logger=self.logger)
image.load_file(filepath)
self.set_image(image) | [
"def",
"load_fits",
"(",
"self",
",",
"filepath",
")",
":",
"image",
"=",
"AstroImage",
".",
"AstroImage",
"(",
"logger",
"=",
"self",
".",
"logger",
")",
"image",
".",
"load_file",
"(",
"filepath",
")",
"self",
".",
"set_image",
"(",
"image",
")"
] | Load a FITS file into the viewer. | [
"Load",
"a",
"FITS",
"file",
"into",
"the",
"viewer",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L96-L103 | train | 24,844 |
ejeschke/ginga | ginga/web/pgw/ipg.py | BasicCanvasView.load_hdu | def load_hdu(self, hdu):
"""
Load an HDU into the viewer.
"""
image = AstroImage.AstroImage(logger=self.logger)
image.load_hdu(hdu)
self.set_image(image) | python | def load_hdu(self, hdu):
"""
Load an HDU into the viewer.
"""
image = AstroImage.AstroImage(logger=self.logger)
image.load_hdu(hdu)
self.set_image(image) | [
"def",
"load_hdu",
"(",
"self",
",",
"hdu",
")",
":",
"image",
"=",
"AstroImage",
".",
"AstroImage",
"(",
"logger",
"=",
"self",
".",
"logger",
")",
"image",
".",
"load_hdu",
"(",
"hdu",
")",
"self",
".",
"set_image",
"(",
"image",
")"
] | Load an HDU into the viewer. | [
"Load",
"an",
"HDU",
"into",
"the",
"viewer",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L107-L114 | train | 24,845 |
ejeschke/ginga | ginga/web/pgw/ipg.py | BasicCanvasView.load_data | def load_data(self, data_np):
"""
Load raw numpy data into the viewer.
"""
image = AstroImage.AstroImage(logger=self.logger)
image.set_data(data_np)
self.set_image(image) | python | def load_data(self, data_np):
"""
Load raw numpy data into the viewer.
"""
image = AstroImage.AstroImage(logger=self.logger)
image.set_data(data_np)
self.set_image(image) | [
"def",
"load_data",
"(",
"self",
",",
"data_np",
")",
":",
"image",
"=",
"AstroImage",
".",
"AstroImage",
"(",
"logger",
"=",
"self",
".",
"logger",
")",
"image",
".",
"set_data",
"(",
"data_np",
")",
"self",
".",
"set_image",
"(",
"image",
")"
] | Load raw numpy data into the viewer. | [
"Load",
"raw",
"numpy",
"data",
"into",
"the",
"viewer",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L116-L123 | train | 24,846 |
ejeschke/ginga | ginga/web/pgw/ipg.py | BasicCanvasView.set_html5_canvas_format | def set_html5_canvas_format(self, fmt):
"""
Sets the format used for rendering to the HTML5 canvas.
'png' offers greater clarity, especially for small text, but
does not have as good of performance as 'jpeg'.
"""
fmt = fmt.lower()
if fmt not in ('jpeg', 'png'):
raise ValueError("Format must be one of {jpeg|png} not '%s'" % (
fmt))
settings = self.get_settings()
settings.set(html5_canvas_format=fmt) | python | def set_html5_canvas_format(self, fmt):
"""
Sets the format used for rendering to the HTML5 canvas.
'png' offers greater clarity, especially for small text, but
does not have as good of performance as 'jpeg'.
"""
fmt = fmt.lower()
if fmt not in ('jpeg', 'png'):
raise ValueError("Format must be one of {jpeg|png} not '%s'" % (
fmt))
settings = self.get_settings()
settings.set(html5_canvas_format=fmt) | [
"def",
"set_html5_canvas_format",
"(",
"self",
",",
"fmt",
")",
":",
"fmt",
"=",
"fmt",
".",
"lower",
"(",
")",
"if",
"fmt",
"not",
"in",
"(",
"'jpeg'",
",",
"'png'",
")",
":",
"raise",
"ValueError",
"(",
"\"Format must be one of {jpeg|png} not '%s'\"",
"%",... | Sets the format used for rendering to the HTML5 canvas.
'png' offers greater clarity, especially for small text, but
does not have as good of performance as 'jpeg'. | [
"Sets",
"the",
"format",
"used",
"for",
"rendering",
"to",
"the",
"HTML5",
"canvas",
".",
"png",
"offers",
"greater",
"clarity",
"especially",
"for",
"small",
"text",
"but",
"does",
"not",
"have",
"as",
"good",
"of",
"performance",
"as",
"jpeg",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L143-L155 | train | 24,847 |
ejeschke/ginga | ginga/web/pgw/ipg.py | EnhancedCanvasView.build_gui | def build_gui(self, container):
"""
This is responsible for building the viewer's UI. It should
place the UI in `container`.
"""
vbox = Widgets.VBox()
vbox.set_border_width(2)
vbox.set_spacing(1)
w = Viewers.GingaViewerWidget(viewer=self)
vbox.add_widget(w, stretch=1)
# set up to capture cursor movement for reading out coordinates
# coordinates reported in base 1 or 0?
self.pixel_base = 1.0
self.readout = Widgets.Label("")
vbox.add_widget(self.readout, stretch=0)
#self.set_callback('none-move', self.motion_cb)
self.set_callback('cursor-changed', self.motion_cb)
# need to put this in an hbox with an expanding label or the
# browser wants to resize the canvas, distorting it
hbox = Widgets.HBox()
hbox.add_widget(vbox, stretch=0)
hbox.add_widget(Widgets.Label(''), stretch=1)
container.set_widget(hbox) | python | def build_gui(self, container):
"""
This is responsible for building the viewer's UI. It should
place the UI in `container`.
"""
vbox = Widgets.VBox()
vbox.set_border_width(2)
vbox.set_spacing(1)
w = Viewers.GingaViewerWidget(viewer=self)
vbox.add_widget(w, stretch=1)
# set up to capture cursor movement for reading out coordinates
# coordinates reported in base 1 or 0?
self.pixel_base = 1.0
self.readout = Widgets.Label("")
vbox.add_widget(self.readout, stretch=0)
#self.set_callback('none-move', self.motion_cb)
self.set_callback('cursor-changed', self.motion_cb)
# need to put this in an hbox with an expanding label or the
# browser wants to resize the canvas, distorting it
hbox = Widgets.HBox()
hbox.add_widget(vbox, stretch=0)
hbox.add_widget(Widgets.Label(''), stretch=1)
container.set_widget(hbox) | [
"def",
"build_gui",
"(",
"self",
",",
"container",
")",
":",
"vbox",
"=",
"Widgets",
".",
"VBox",
"(",
")",
"vbox",
".",
"set_border_width",
"(",
"2",
")",
"vbox",
".",
"set_spacing",
"(",
"1",
")",
"w",
"=",
"Viewers",
".",
"GingaViewerWidget",
"(",
... | This is responsible for building the viewer's UI. It should
place the UI in `container`. | [
"This",
"is",
"responsible",
"for",
"building",
"the",
"viewer",
"s",
"UI",
".",
"It",
"should",
"place",
"the",
"UI",
"in",
"container",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L168-L197 | train | 24,848 |
ejeschke/ginga | ginga/web/pgw/ipg.py | ViewerFactory.get_viewer | def get_viewer(self, v_id, viewer_class=None, width=512, height=512,
force_new=False):
"""
Get an existing viewer by viewer id. If the viewer does not yet
exist, make a new one.
"""
if not force_new:
try:
return self.viewers[v_id]
except KeyError:
pass
# create top level window
window = self.app.make_window("Viewer %s" % v_id, wid=v_id)
# We get back a record with information about the viewer
v_info = self.make_viewer(window, viewer_class=viewer_class,
width=width, height=height)
# Save it under this viewer id
self.viewers[v_id] = v_info
return v_info | python | def get_viewer(self, v_id, viewer_class=None, width=512, height=512,
force_new=False):
"""
Get an existing viewer by viewer id. If the viewer does not yet
exist, make a new one.
"""
if not force_new:
try:
return self.viewers[v_id]
except KeyError:
pass
# create top level window
window = self.app.make_window("Viewer %s" % v_id, wid=v_id)
# We get back a record with information about the viewer
v_info = self.make_viewer(window, viewer_class=viewer_class,
width=width, height=height)
# Save it under this viewer id
self.viewers[v_id] = v_info
return v_info | [
"def",
"get_viewer",
"(",
"self",
",",
"v_id",
",",
"viewer_class",
"=",
"None",
",",
"width",
"=",
"512",
",",
"height",
"=",
"512",
",",
"force_new",
"=",
"False",
")",
":",
"if",
"not",
"force_new",
":",
"try",
":",
"return",
"self",
".",
"viewers... | Get an existing viewer by viewer id. If the viewer does not yet
exist, make a new one. | [
"Get",
"an",
"existing",
"viewer",
"by",
"viewer",
"id",
".",
"If",
"the",
"viewer",
"does",
"not",
"yet",
"exist",
"make",
"a",
"new",
"one",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ipg.py#L315-L336 | train | 24,849 |
ejeschke/ginga | ginga/rv/plugins/Pick.py | Pick.detailxy | def detailxy(self, canvas, button, data_x, data_y):
"""Motion event in the pick fits window. Show the pointing
information under the cursor.
"""
if button == 0:
# TODO: we could track the focus changes to make this check
# more efficient
chviewer = self.fv.getfocus_viewer()
# Don't update global information if our chviewer isn't focused
if chviewer != self.fitsimage:
return True
# Add offsets from cutout
data_x = data_x + self.pick_x1
data_y = data_y + self.pick_y1
return self.fv.showxy(chviewer, data_x, data_y) | python | def detailxy(self, canvas, button, data_x, data_y):
"""Motion event in the pick fits window. Show the pointing
information under the cursor.
"""
if button == 0:
# TODO: we could track the focus changes to make this check
# more efficient
chviewer = self.fv.getfocus_viewer()
# Don't update global information if our chviewer isn't focused
if chviewer != self.fitsimage:
return True
# Add offsets from cutout
data_x = data_x + self.pick_x1
data_y = data_y + self.pick_y1
return self.fv.showxy(chviewer, data_x, data_y) | [
"def",
"detailxy",
"(",
"self",
",",
"canvas",
",",
"button",
",",
"data_x",
",",
"data_y",
")",
":",
"if",
"button",
"==",
"0",
":",
"# TODO: we could track the focus changes to make this check",
"# more efficient",
"chviewer",
"=",
"self",
".",
"fv",
".",
"get... | Motion event in the pick fits window. Show the pointing
information under the cursor. | [
"Motion",
"event",
"in",
"the",
"pick",
"fits",
"window",
".",
"Show",
"the",
"pointing",
"information",
"under",
"the",
"cursor",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Pick.py#L1855-L1871 | train | 24,850 |
ejeschke/ginga | ginga/rv/main.py | reference_viewer | def reference_viewer(sys_argv):
"""Create reference viewer from command line."""
viewer = ReferenceViewer(layout=default_layout)
viewer.add_default_plugins()
viewer.add_separately_distributed_plugins()
# Parse command line options with optparse module
from optparse import OptionParser
usage = "usage: %prog [options] cmd [args]"
optprs = OptionParser(usage=usage,
version=('%%prog %s' % version.version))
viewer.add_default_options(optprs)
(options, args) = optprs.parse_args(sys_argv[1:])
if options.display:
os.environ['DISPLAY'] = options.display
# Are we debugging this?
if options.debug:
import pdb
pdb.run('viewer.main(options, args)')
# Are we profiling this?
elif options.profile:
import profile
print(("%s profile:" % sys_argv[0]))
profile.run('viewer.main(options, args)')
else:
viewer.main(options, args) | python | def reference_viewer(sys_argv):
"""Create reference viewer from command line."""
viewer = ReferenceViewer(layout=default_layout)
viewer.add_default_plugins()
viewer.add_separately_distributed_plugins()
# Parse command line options with optparse module
from optparse import OptionParser
usage = "usage: %prog [options] cmd [args]"
optprs = OptionParser(usage=usage,
version=('%%prog %s' % version.version))
viewer.add_default_options(optprs)
(options, args) = optprs.parse_args(sys_argv[1:])
if options.display:
os.environ['DISPLAY'] = options.display
# Are we debugging this?
if options.debug:
import pdb
pdb.run('viewer.main(options, args)')
# Are we profiling this?
elif options.profile:
import profile
print(("%s profile:" % sys_argv[0]))
profile.run('viewer.main(options, args)')
else:
viewer.main(options, args) | [
"def",
"reference_viewer",
"(",
"sys_argv",
")",
":",
"viewer",
"=",
"ReferenceViewer",
"(",
"layout",
"=",
"default_layout",
")",
"viewer",
".",
"add_default_plugins",
"(",
")",
"viewer",
".",
"add_separately_distributed_plugins",
"(",
")",
"# Parse command line opti... | Create reference viewer from command line. | [
"Create",
"reference",
"viewer",
"from",
"command",
"line",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/main.py#L692-L725 | train | 24,851 |
ejeschke/ginga | ginga/rv/main.py | ReferenceViewer.add_default_plugins | def add_default_plugins(self, except_global=[], except_local=[]):
"""
Add the ginga-distributed default set of plugins to the
reference viewer.
"""
# add default global plugins
for spec in plugins:
ptype = spec.get('ptype', 'local')
if ptype == 'global' and spec.module not in except_global:
self.add_plugin_spec(spec)
if ptype == 'local' and spec.module not in except_local:
self.add_plugin_spec(spec) | python | def add_default_plugins(self, except_global=[], except_local=[]):
"""
Add the ginga-distributed default set of plugins to the
reference viewer.
"""
# add default global plugins
for spec in plugins:
ptype = spec.get('ptype', 'local')
if ptype == 'global' and spec.module not in except_global:
self.add_plugin_spec(spec)
if ptype == 'local' and spec.module not in except_local:
self.add_plugin_spec(spec) | [
"def",
"add_default_plugins",
"(",
"self",
",",
"except_global",
"=",
"[",
"]",
",",
"except_local",
"=",
"[",
"]",
")",
":",
"# add default global plugins",
"for",
"spec",
"in",
"plugins",
":",
"ptype",
"=",
"spec",
".",
"get",
"(",
"'ptype'",
",",
"'loca... | Add the ginga-distributed default set of plugins to the
reference viewer. | [
"Add",
"the",
"ginga",
"-",
"distributed",
"default",
"set",
"of",
"plugins",
"to",
"the",
"reference",
"viewer",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/main.py#L181-L193 | train | 24,852 |
ejeschke/ginga | ginga/rv/main.py | ReferenceViewer.add_default_options | def add_default_options(self, optprs):
"""
Adds the default reference viewer startup options to an
OptionParser instance `optprs`.
"""
optprs.add_option("--bufsize", dest="bufsize", metavar="NUM",
type="int", default=10,
help="Buffer length to NUM")
optprs.add_option('-c', "--channels", dest="channels",
help="Specify list of channels to create")
optprs.add_option("--debug", dest="debug", default=False,
action="store_true",
help="Enter the pdb debugger on main()")
optprs.add_option("--disable-plugins", dest="disable_plugins",
metavar="NAMES",
help="Specify plugins that should be disabled")
optprs.add_option("--display", dest="display", metavar="HOST:N",
help="Use X display on HOST:N")
optprs.add_option("--fitspkg", dest="fitspkg", metavar="NAME",
default=None,
help="Prefer FITS I/O module NAME")
optprs.add_option("-g", "--geometry", dest="geometry",
default=None, metavar="GEOM",
help="X geometry for initial size and placement")
optprs.add_option("--modules", dest="modules", metavar="NAMES",
help="Specify additional modules to load")
optprs.add_option("--norestore", dest="norestore", default=False,
action="store_true",
help="Don't restore the GUI from a saved layout")
optprs.add_option("--nosplash", dest="nosplash", default=False,
action="store_true",
help="Don't display the splash screen")
optprs.add_option("--numthreads", dest="numthreads", type="int",
default=30, metavar="NUM",
help="Start NUM threads in thread pool")
optprs.add_option("--opencv", dest="opencv", default=False,
action="store_true",
help="Use OpenCv acceleration")
optprs.add_option("--opencl", dest="opencl", default=False,
action="store_true",
help="Use OpenCL acceleration")
optprs.add_option("--plugins", dest="plugins", metavar="NAMES",
help="Specify additional plugins to load")
optprs.add_option("--profile", dest="profile", action="store_true",
default=False,
help="Run the profiler on main()")
optprs.add_option("--sep", dest="separate_channels", default=False,
action="store_true",
help="Load files in separate channels")
optprs.add_option("-t", "--toolkit", dest="toolkit", metavar="NAME",
default=None,
help="Prefer GUI toolkit (gtk|qt)")
optprs.add_option("--wcspkg", dest="wcspkg", metavar="NAME",
default=None,
help="Prefer WCS module NAME")
log.addlogopts(optprs) | python | def add_default_options(self, optprs):
"""
Adds the default reference viewer startup options to an
OptionParser instance `optprs`.
"""
optprs.add_option("--bufsize", dest="bufsize", metavar="NUM",
type="int", default=10,
help="Buffer length to NUM")
optprs.add_option('-c', "--channels", dest="channels",
help="Specify list of channels to create")
optprs.add_option("--debug", dest="debug", default=False,
action="store_true",
help="Enter the pdb debugger on main()")
optprs.add_option("--disable-plugins", dest="disable_plugins",
metavar="NAMES",
help="Specify plugins that should be disabled")
optprs.add_option("--display", dest="display", metavar="HOST:N",
help="Use X display on HOST:N")
optprs.add_option("--fitspkg", dest="fitspkg", metavar="NAME",
default=None,
help="Prefer FITS I/O module NAME")
optprs.add_option("-g", "--geometry", dest="geometry",
default=None, metavar="GEOM",
help="X geometry for initial size and placement")
optprs.add_option("--modules", dest="modules", metavar="NAMES",
help="Specify additional modules to load")
optprs.add_option("--norestore", dest="norestore", default=False,
action="store_true",
help="Don't restore the GUI from a saved layout")
optprs.add_option("--nosplash", dest="nosplash", default=False,
action="store_true",
help="Don't display the splash screen")
optprs.add_option("--numthreads", dest="numthreads", type="int",
default=30, metavar="NUM",
help="Start NUM threads in thread pool")
optprs.add_option("--opencv", dest="opencv", default=False,
action="store_true",
help="Use OpenCv acceleration")
optprs.add_option("--opencl", dest="opencl", default=False,
action="store_true",
help="Use OpenCL acceleration")
optprs.add_option("--plugins", dest="plugins", metavar="NAMES",
help="Specify additional plugins to load")
optprs.add_option("--profile", dest="profile", action="store_true",
default=False,
help="Run the profiler on main()")
optprs.add_option("--sep", dest="separate_channels", default=False,
action="store_true",
help="Load files in separate channels")
optprs.add_option("-t", "--toolkit", dest="toolkit", metavar="NAME",
default=None,
help="Prefer GUI toolkit (gtk|qt)")
optprs.add_option("--wcspkg", dest="wcspkg", metavar="NAME",
default=None,
help="Prefer WCS module NAME")
log.addlogopts(optprs) | [
"def",
"add_default_options",
"(",
"self",
",",
"optprs",
")",
":",
"optprs",
".",
"add_option",
"(",
"\"--bufsize\"",
",",
"dest",
"=",
"\"bufsize\"",
",",
"metavar",
"=",
"\"NUM\"",
",",
"type",
"=",
"\"int\"",
",",
"default",
"=",
"10",
",",
"help",
"... | Adds the default reference viewer startup options to an
OptionParser instance `optprs`. | [
"Adds",
"the",
"default",
"reference",
"viewer",
"startup",
"options",
"to",
"an",
"OptionParser",
"instance",
"optprs",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/main.py#L219-L274 | train | 24,853 |
ejeschke/ginga | ginga/gw/GwMain.py | GwMain.gui_call | def gui_call(self, method, *args, **kwdargs):
"""General method for synchronously calling into the GUI.
This waits until the method has completed before returning.
"""
my_id = thread.get_ident()
if my_id == self.gui_thread_id:
return method(*args, **kwdargs)
else:
future = self.gui_do(method, *args, **kwdargs)
return future.wait() | python | def gui_call(self, method, *args, **kwdargs):
"""General method for synchronously calling into the GUI.
This waits until the method has completed before returning.
"""
my_id = thread.get_ident()
if my_id == self.gui_thread_id:
return method(*args, **kwdargs)
else:
future = self.gui_do(method, *args, **kwdargs)
return future.wait() | [
"def",
"gui_call",
"(",
"self",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwdargs",
")",
":",
"my_id",
"=",
"thread",
".",
"get_ident",
"(",
")",
"if",
"my_id",
"==",
"self",
".",
"gui_thread_id",
":",
"return",
"method",
"(",
"*",
"args",
"... | General method for synchronously calling into the GUI.
This waits until the method has completed before returning. | [
"General",
"method",
"for",
"synchronously",
"calling",
"into",
"the",
"GUI",
".",
"This",
"waits",
"until",
"the",
"method",
"has",
"completed",
"before",
"returning",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/gw/GwMain.py#L170-L179 | train | 24,854 |
ejeschke/ginga | ginga/rv/plugins/WBrowser.py | WBrowser.show_help | def show_help(self, plugin=None, no_url_callback=None):
"""See `~ginga.GingaPlugin` for usage of optional keywords."""
if not Widgets.has_webkit:
return
self.fv.nongui_do(self._download_doc, plugin=plugin,
no_url_callback=no_url_callback) | python | def show_help(self, plugin=None, no_url_callback=None):
"""See `~ginga.GingaPlugin` for usage of optional keywords."""
if not Widgets.has_webkit:
return
self.fv.nongui_do(self._download_doc, plugin=plugin,
no_url_callback=no_url_callback) | [
"def",
"show_help",
"(",
"self",
",",
"plugin",
"=",
"None",
",",
"no_url_callback",
"=",
"None",
")",
":",
"if",
"not",
"Widgets",
".",
"has_webkit",
":",
"return",
"self",
".",
"fv",
".",
"nongui_do",
"(",
"self",
".",
"_download_doc",
",",
"plugin",
... | See `~ginga.GingaPlugin` for usage of optional keywords. | [
"See",
"~ginga",
".",
"GingaPlugin",
"for",
"usage",
"of",
"optional",
"keywords",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/WBrowser.py#L129-L135 | train | 24,855 |
ejeschke/ginga | ginga/util/iqcalc.py | get_mean | def get_mean(data_np):
"""Calculate mean for valid values.
Parameters
----------
data_np : ndarray
Input array.
Returns
-------
result : float
Mean of array values that are finite.
If array contains no finite values, returns NaN.
"""
i = np.isfinite(data_np)
if not np.any(i):
return np.nan
return np.mean(data_np[i]) | python | def get_mean(data_np):
"""Calculate mean for valid values.
Parameters
----------
data_np : ndarray
Input array.
Returns
-------
result : float
Mean of array values that are finite.
If array contains no finite values, returns NaN.
"""
i = np.isfinite(data_np)
if not np.any(i):
return np.nan
return np.mean(data_np[i]) | [
"def",
"get_mean",
"(",
"data_np",
")",
":",
"i",
"=",
"np",
".",
"isfinite",
"(",
"data_np",
")",
"if",
"not",
"np",
".",
"any",
"(",
"i",
")",
":",
"return",
"np",
".",
"nan",
"return",
"np",
".",
"mean",
"(",
"data_np",
"[",
"i",
"]",
")"
] | Calculate mean for valid values.
Parameters
----------
data_np : ndarray
Input array.
Returns
-------
result : float
Mean of array values that are finite.
If array contains no finite values, returns NaN. | [
"Calculate",
"mean",
"for",
"valid",
"values",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/iqcalc.py#L25-L43 | train | 24,856 |
ejeschke/ginga | ginga/util/iqcalc.py | IQCalc.calc_fwhm_gaussian | def calc_fwhm_gaussian(self, arr1d, medv=None, gauss_fn=None):
"""FWHM calculation on a 1D array by using least square fitting of
a gaussian function on the data. arr1d is a 1D array cut in either
X or Y direction on the object.
"""
if gauss_fn is None:
gauss_fn = self.gaussian
N = len(arr1d)
X = np.array(list(range(N)))
Y = arr1d
# Fitting works more reliably if we do the following
# a. subtract sky background
if medv is None:
medv = get_median(Y)
Y = Y - medv
maxv = Y.max()
# b. clamp to 0..max (of the sky subtracted field)
Y = Y.clip(0, maxv)
# Fit a gaussian
p0 = [0, N - 1, maxv] # Inital guess
# Distance to the target function
errfunc = lambda p, x, y: gauss_fn(x, p) - y # noqa
# Least square fit to the gaussian
with self.lock:
# NOTE: without this mutex, optimize.leastsq causes a fatal error
# sometimes--it appears not to be thread safe.
# The error is:
# "SystemError: null argument to internal routine"
# "Fatal Python error: GC object already tracked"
p1, success = optimize.leastsq(errfunc, p0[:], args=(X, Y))
if not success:
raise IQCalcError("FWHM gaussian fitting failed")
mu, sdev, maxv = p1
self.logger.debug("mu=%f sdev=%f maxv=%f" % (mu, sdev, maxv))
# Now that we have the sdev from fitting, we can calculate FWHM
fwhm = 2.0 * np.sqrt(2.0 * np.log(2.0)) * sdev
# some routines choke on numpy values and need "pure" Python floats
# e.g. when marshalling through a remote procedure interface
fwhm = float(fwhm)
mu = float(mu)
sdev = float(sdev)
maxv = float(maxv)
res = Bunch.Bunch(fwhm=fwhm, mu=mu, sdev=sdev, maxv=maxv,
fit_fn=gauss_fn, fit_args=[mu, sdev, maxv])
return res | python | def calc_fwhm_gaussian(self, arr1d, medv=None, gauss_fn=None):
"""FWHM calculation on a 1D array by using least square fitting of
a gaussian function on the data. arr1d is a 1D array cut in either
X or Y direction on the object.
"""
if gauss_fn is None:
gauss_fn = self.gaussian
N = len(arr1d)
X = np.array(list(range(N)))
Y = arr1d
# Fitting works more reliably if we do the following
# a. subtract sky background
if medv is None:
medv = get_median(Y)
Y = Y - medv
maxv = Y.max()
# b. clamp to 0..max (of the sky subtracted field)
Y = Y.clip(0, maxv)
# Fit a gaussian
p0 = [0, N - 1, maxv] # Inital guess
# Distance to the target function
errfunc = lambda p, x, y: gauss_fn(x, p) - y # noqa
# Least square fit to the gaussian
with self.lock:
# NOTE: without this mutex, optimize.leastsq causes a fatal error
# sometimes--it appears not to be thread safe.
# The error is:
# "SystemError: null argument to internal routine"
# "Fatal Python error: GC object already tracked"
p1, success = optimize.leastsq(errfunc, p0[:], args=(X, Y))
if not success:
raise IQCalcError("FWHM gaussian fitting failed")
mu, sdev, maxv = p1
self.logger.debug("mu=%f sdev=%f maxv=%f" % (mu, sdev, maxv))
# Now that we have the sdev from fitting, we can calculate FWHM
fwhm = 2.0 * np.sqrt(2.0 * np.log(2.0)) * sdev
# some routines choke on numpy values and need "pure" Python floats
# e.g. when marshalling through a remote procedure interface
fwhm = float(fwhm)
mu = float(mu)
sdev = float(sdev)
maxv = float(maxv)
res = Bunch.Bunch(fwhm=fwhm, mu=mu, sdev=sdev, maxv=maxv,
fit_fn=gauss_fn, fit_args=[mu, sdev, maxv])
return res | [
"def",
"calc_fwhm_gaussian",
"(",
"self",
",",
"arr1d",
",",
"medv",
"=",
"None",
",",
"gauss_fn",
"=",
"None",
")",
":",
"if",
"gauss_fn",
"is",
"None",
":",
"gauss_fn",
"=",
"self",
".",
"gaussian",
"N",
"=",
"len",
"(",
"arr1d",
")",
"X",
"=",
"... | FWHM calculation on a 1D array by using least square fitting of
a gaussian function on the data. arr1d is a 1D array cut in either
X or Y direction on the object. | [
"FWHM",
"calculation",
"on",
"a",
"1D",
"array",
"by",
"using",
"least",
"square",
"fitting",
"of",
"a",
"gaussian",
"function",
"on",
"the",
"data",
".",
"arr1d",
"is",
"a",
"1D",
"array",
"cut",
"in",
"either",
"X",
"or",
"Y",
"direction",
"on",
"the... | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/iqcalc.py#L85-L135 | train | 24,857 |
ejeschke/ginga | ginga/util/iqcalc.py | IQCalc.calc_fwhm_moffat | def calc_fwhm_moffat(self, arr1d, medv=None, moffat_fn=None):
"""FWHM calculation on a 1D array by using least square fitting of
a Moffat function on the data. arr1d is a 1D array cut in either
X or Y direction on the object.
"""
if moffat_fn is None:
moffat_fn = self.moffat
N = len(arr1d)
X = np.array(list(range(N)))
Y = arr1d
# Fitting works more reliably if we do the following
# a. subtract sky background
if medv is None:
medv = get_median(Y)
Y = Y - medv
maxv = Y.max()
# b. clamp to 0..max (of the sky subtracted field)
Y = Y.clip(0, maxv)
# Fit a moffat
p0 = [0, N - 1, 2, maxv] # Inital guess
# Distance to the target function
errfunc = lambda p, x, y: moffat_fn(x, p) - y # noqa
# Least square fit to the gaussian
with self.lock:
# NOTE: without this mutex, optimize.leastsq causes a fatal error
# sometimes--it appears not to be thread safe.
# The error is:
# "SystemError: null argument to internal routine"
# "Fatal Python error: GC object already tracked"
p1, success = optimize.leastsq(errfunc, p0[:], args=(X, Y))
if not success:
raise IQCalcError("FWHM moffat fitting failed")
mu, width, power, maxv = p1
width = np.abs(width)
self.logger.debug("mu=%f width=%f power=%f maxv=%f" % (
mu, width, power, maxv))
fwhm = 2.0 * width * np.sqrt(2.0 ** (1.0 / power) - 1.0)
# some routines choke on numpy values and need "pure" Python floats
# e.g. when marshalling through a remote procedure interface
fwhm = float(fwhm)
mu = float(mu)
width = float(width)
power = float(power)
maxv = float(maxv)
res = Bunch.Bunch(fwhm=fwhm, mu=mu, width=width, power=power,
maxv=maxv, fit_fn=moffat_fn,
fit_args=[mu, width, power, maxv])
return res | python | def calc_fwhm_moffat(self, arr1d, medv=None, moffat_fn=None):
"""FWHM calculation on a 1D array by using least square fitting of
a Moffat function on the data. arr1d is a 1D array cut in either
X or Y direction on the object.
"""
if moffat_fn is None:
moffat_fn = self.moffat
N = len(arr1d)
X = np.array(list(range(N)))
Y = arr1d
# Fitting works more reliably if we do the following
# a. subtract sky background
if medv is None:
medv = get_median(Y)
Y = Y - medv
maxv = Y.max()
# b. clamp to 0..max (of the sky subtracted field)
Y = Y.clip(0, maxv)
# Fit a moffat
p0 = [0, N - 1, 2, maxv] # Inital guess
# Distance to the target function
errfunc = lambda p, x, y: moffat_fn(x, p) - y # noqa
# Least square fit to the gaussian
with self.lock:
# NOTE: without this mutex, optimize.leastsq causes a fatal error
# sometimes--it appears not to be thread safe.
# The error is:
# "SystemError: null argument to internal routine"
# "Fatal Python error: GC object already tracked"
p1, success = optimize.leastsq(errfunc, p0[:], args=(X, Y))
if not success:
raise IQCalcError("FWHM moffat fitting failed")
mu, width, power, maxv = p1
width = np.abs(width)
self.logger.debug("mu=%f width=%f power=%f maxv=%f" % (
mu, width, power, maxv))
fwhm = 2.0 * width * np.sqrt(2.0 ** (1.0 / power) - 1.0)
# some routines choke on numpy values and need "pure" Python floats
# e.g. when marshalling through a remote procedure interface
fwhm = float(fwhm)
mu = float(mu)
width = float(width)
power = float(power)
maxv = float(maxv)
res = Bunch.Bunch(fwhm=fwhm, mu=mu, width=width, power=power,
maxv=maxv, fit_fn=moffat_fn,
fit_args=[mu, width, power, maxv])
return res | [
"def",
"calc_fwhm_moffat",
"(",
"self",
",",
"arr1d",
",",
"medv",
"=",
"None",
",",
"moffat_fn",
"=",
"None",
")",
":",
"if",
"moffat_fn",
"is",
"None",
":",
"moffat_fn",
"=",
"self",
".",
"moffat",
"N",
"=",
"len",
"(",
"arr1d",
")",
"X",
"=",
"n... | FWHM calculation on a 1D array by using least square fitting of
a Moffat function on the data. arr1d is a 1D array cut in either
X or Y direction on the object. | [
"FWHM",
"calculation",
"on",
"a",
"1D",
"array",
"by",
"using",
"least",
"square",
"fitting",
"of",
"a",
"Moffat",
"function",
"on",
"the",
"data",
".",
"arr1d",
"is",
"a",
"1D",
"array",
"cut",
"in",
"either",
"X",
"or",
"Y",
"direction",
"on",
"the",... | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/iqcalc.py#L144-L198 | train | 24,858 |
ejeschke/ginga | ginga/misc/ModuleManager.py | my_import | def my_import(name, path=None):
"""Return imported module for the given name."""
# Documentation for importlib says this may be needed to pick up
# modules created after the program has started
if hasattr(importlib, 'invalidate_caches'):
# python 3.3+
importlib.invalidate_caches()
if path is not None:
directory, src_file = os.path.split(path)
# TODO: use the importlib.util machinery
sys.path.insert(0, directory)
try:
mod = importlib.import_module(name)
finally:
sys.path.pop(0)
else:
mod = importlib.import_module(name)
return mod | python | def my_import(name, path=None):
"""Return imported module for the given name."""
# Documentation for importlib says this may be needed to pick up
# modules created after the program has started
if hasattr(importlib, 'invalidate_caches'):
# python 3.3+
importlib.invalidate_caches()
if path is not None:
directory, src_file = os.path.split(path)
# TODO: use the importlib.util machinery
sys.path.insert(0, directory)
try:
mod = importlib.import_module(name)
finally:
sys.path.pop(0)
else:
mod = importlib.import_module(name)
return mod | [
"def",
"my_import",
"(",
"name",
",",
"path",
"=",
"None",
")",
":",
"# Documentation for importlib says this may be needed to pick up",
"# modules created after the program has started",
"if",
"hasattr",
"(",
"importlib",
",",
"'invalidate_caches'",
")",
":",
"# python 3.3+"... | Return imported module for the given name. | [
"Return",
"imported",
"module",
"for",
"the",
"given",
"name",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/misc/ModuleManager.py#L19-L41 | train | 24,859 |
ejeschke/ginga | ginga/misc/ModuleManager.py | ModuleManager.get_module | def get_module(self, module_name):
"""Return loaded module from the given name."""
try:
return self.module[module_name]
except KeyError:
return sys.modules[module_name] | python | def get_module(self, module_name):
"""Return loaded module from the given name."""
try:
return self.module[module_name]
except KeyError:
return sys.modules[module_name] | [
"def",
"get_module",
"(",
"self",
",",
"module_name",
")",
":",
"try",
":",
"return",
"self",
".",
"module",
"[",
"module_name",
"]",
"except",
"KeyError",
":",
"return",
"sys",
".",
"modules",
"[",
"module_name",
"]"
] | Return loaded module from the given name. | [
"Return",
"loaded",
"module",
"from",
"the",
"given",
"name",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/misc/ModuleManager.py#L82-L88 | train | 24,860 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.parse_combo | def parse_combo(self, combo, modes_set, modifiers_set, pfx):
"""
Parse a string into a mode, a set of modifiers and a trigger.
"""
mode, mods, trigger = None, set([]), combo
if '+' in combo:
if combo.endswith('+'):
# special case: probably contains the keystroke '+'
trigger, combo = '+', combo[:-1]
if '+' in combo:
items = set(combo.split('+'))
else:
items = set(combo)
else:
# trigger is always specified last
items = combo.split('+')
trigger, items = items[-1], set(items[:-1])
if '*' in items:
items.remove('*')
# modifier wildcard
mods = '*'
else:
mods = items.intersection(modifiers_set)
mode = items.intersection(modes_set)
if len(mode) == 0:
mode = None
else:
mode = mode.pop()
if pfx is not None:
trigger = pfx + trigger
return (mode, mods, trigger) | python | def parse_combo(self, combo, modes_set, modifiers_set, pfx):
"""
Parse a string into a mode, a set of modifiers and a trigger.
"""
mode, mods, trigger = None, set([]), combo
if '+' in combo:
if combo.endswith('+'):
# special case: probably contains the keystroke '+'
trigger, combo = '+', combo[:-1]
if '+' in combo:
items = set(combo.split('+'))
else:
items = set(combo)
else:
# trigger is always specified last
items = combo.split('+')
trigger, items = items[-1], set(items[:-1])
if '*' in items:
items.remove('*')
# modifier wildcard
mods = '*'
else:
mods = items.intersection(modifiers_set)
mode = items.intersection(modes_set)
if len(mode) == 0:
mode = None
else:
mode = mode.pop()
if pfx is not None:
trigger = pfx + trigger
return (mode, mods, trigger) | [
"def",
"parse_combo",
"(",
"self",
",",
"combo",
",",
"modes_set",
",",
"modifiers_set",
",",
"pfx",
")",
":",
"mode",
",",
"mods",
",",
"trigger",
"=",
"None",
",",
"set",
"(",
"[",
"]",
")",
",",
"combo",
"if",
"'+'",
"in",
"combo",
":",
"if",
... | Parse a string into a mode, a set of modifiers and a trigger. | [
"Parse",
"a",
"string",
"into",
"a",
"mode",
"a",
"set",
"of",
"modifiers",
"and",
"a",
"trigger",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L272-L306 | train | 24,861 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.get_direction | def get_direction(self, direction, rev=False):
"""
Translate a direction in compass degrees into 'up' or 'down'.
"""
if (direction < 90.0) or (direction >= 270.0):
if not rev:
return 'up'
else:
return 'down'
elif (90.0 <= direction < 270.0):
if not rev:
return 'down'
else:
return 'up'
else:
return 'none' | python | def get_direction(self, direction, rev=False):
"""
Translate a direction in compass degrees into 'up' or 'down'.
"""
if (direction < 90.0) or (direction >= 270.0):
if not rev:
return 'up'
else:
return 'down'
elif (90.0 <= direction < 270.0):
if not rev:
return 'down'
else:
return 'up'
else:
return 'none' | [
"def",
"get_direction",
"(",
"self",
",",
"direction",
",",
"rev",
"=",
"False",
")",
":",
"if",
"(",
"direction",
"<",
"90.0",
")",
"or",
"(",
"direction",
">=",
"270.0",
")",
":",
"if",
"not",
"rev",
":",
"return",
"'up'",
"else",
":",
"return",
... | Translate a direction in compass degrees into 'up' or 'down'. | [
"Translate",
"a",
"direction",
"in",
"compass",
"degrees",
"into",
"up",
"or",
"down",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L706-L721 | train | 24,862 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.kp_pan_px_center | def kp_pan_px_center(self, viewer, event, data_x, data_y, msg=True):
"""This pans so that the cursor is over the center of the
current pixel."""
if not self.canpan:
return False
self.pan_center_px(viewer)
return True | python | def kp_pan_px_center(self, viewer, event, data_x, data_y, msg=True):
"""This pans so that the cursor is over the center of the
current pixel."""
if not self.canpan:
return False
self.pan_center_px(viewer)
return True | [
"def",
"kp_pan_px_center",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
",",
"msg",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"canpan",
":",
"return",
"False",
"self",
".",
"pan_center_px",
"(",
"viewer",
")",
"return"... | This pans so that the cursor is over the center of the
current pixel. | [
"This",
"pans",
"so",
"that",
"the",
"cursor",
"is",
"over",
"the",
"center",
"of",
"the",
"current",
"pixel",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1214-L1220 | train | 24,863 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_zoom | def ms_zoom(self, viewer, event, data_x, data_y, msg=True):
"""Zoom the image by dragging the cursor left or right.
"""
if not self.canzoom:
return True
msg = self.settings.get('msg_zoom', msg)
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._zoom_xy(viewer, x, y)
elif event.state == 'down':
if msg:
viewer.onscreen_message("Zoom (drag mouse L-R)",
delay=1.0)
self._start_x, self._start_y = x, y
else:
viewer.onscreen_message(None)
return True | python | def ms_zoom(self, viewer, event, data_x, data_y, msg=True):
"""Zoom the image by dragging the cursor left or right.
"""
if not self.canzoom:
return True
msg = self.settings.get('msg_zoom', msg)
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._zoom_xy(viewer, x, y)
elif event.state == 'down':
if msg:
viewer.onscreen_message("Zoom (drag mouse L-R)",
delay=1.0)
self._start_x, self._start_y = x, y
else:
viewer.onscreen_message(None)
return True | [
"def",
"ms_zoom",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
",",
"msg",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"canzoom",
":",
"return",
"True",
"msg",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"'msg_zoo... | Zoom the image by dragging the cursor left or right. | [
"Zoom",
"the",
"image",
"by",
"dragging",
"the",
"cursor",
"left",
"or",
"right",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1554-L1574 | train | 24,864 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_zoom_in | def ms_zoom_in(self, viewer, event, data_x, data_y, msg=False):
"""Zoom in one level by a mouse click.
"""
if not self.canzoom:
return True
if not (event.state == 'down'):
return True
with viewer.suppress_redraw:
viewer.panset_xy(data_x, data_y)
if self.settings.get('scroll_zoom_direct_scale', True):
zoom_accel = self.settings.get('scroll_zoom_acceleration', 1.0)
# change scale by 100%
amount = self._scale_adjust(2.0, 15.0, zoom_accel, max_limit=4.0)
self._scale_image(viewer, 0.0, amount, msg=msg)
else:
viewer.zoom_in()
if hasattr(viewer, 'center_cursor'):
viewer.center_cursor()
if msg:
viewer.onscreen_message(viewer.get_scale_text(),
delay=1.0)
return True | python | def ms_zoom_in(self, viewer, event, data_x, data_y, msg=False):
"""Zoom in one level by a mouse click.
"""
if not self.canzoom:
return True
if not (event.state == 'down'):
return True
with viewer.suppress_redraw:
viewer.panset_xy(data_x, data_y)
if self.settings.get('scroll_zoom_direct_scale', True):
zoom_accel = self.settings.get('scroll_zoom_acceleration', 1.0)
# change scale by 100%
amount = self._scale_adjust(2.0, 15.0, zoom_accel, max_limit=4.0)
self._scale_image(viewer, 0.0, amount, msg=msg)
else:
viewer.zoom_in()
if hasattr(viewer, 'center_cursor'):
viewer.center_cursor()
if msg:
viewer.onscreen_message(viewer.get_scale_text(),
delay=1.0)
return True | [
"def",
"ms_zoom_in",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
",",
"msg",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"canzoom",
":",
"return",
"True",
"if",
"not",
"(",
"event",
".",
"state",
"==",
"'down'",
")... | Zoom in one level by a mouse click. | [
"Zoom",
"in",
"one",
"level",
"by",
"a",
"mouse",
"click",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1585-L1610 | train | 24,865 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_rotate | def ms_rotate(self, viewer, event, data_x, data_y, msg=True):
"""Rotate the image by dragging the cursor left or right.
"""
if not self.canrotate:
return True
msg = self.settings.get('msg_rotate', msg)
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._rotate_xy(viewer, x, y)
elif event.state == 'down':
if msg:
viewer.onscreen_message("Rotate (drag around center)",
delay=1.0)
self._start_x, self._start_y = x, y
self._start_rot = viewer.get_rotation()
else:
viewer.onscreen_message(None)
return True | python | def ms_rotate(self, viewer, event, data_x, data_y, msg=True):
"""Rotate the image by dragging the cursor left or right.
"""
if not self.canrotate:
return True
msg = self.settings.get('msg_rotate', msg)
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._rotate_xy(viewer, x, y)
elif event.state == 'down':
if msg:
viewer.onscreen_message("Rotate (drag around center)",
delay=1.0)
self._start_x, self._start_y = x, y
self._start_rot = viewer.get_rotation()
else:
viewer.onscreen_message(None)
return True | [
"def",
"ms_rotate",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
",",
"msg",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"canrotate",
":",
"return",
"True",
"msg",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"'msg... | Rotate the image by dragging the cursor left or right. | [
"Rotate",
"the",
"image",
"by",
"dragging",
"the",
"cursor",
"left",
"or",
"right",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1641-L1662 | train | 24,866 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_contrast | def ms_contrast(self, viewer, event, data_x, data_y, msg=True):
"""Shift the colormap by dragging the cursor left or right.
Stretch the colormap by dragging the cursor up or down.
"""
if not self.cancmap:
return True
msg = self.settings.get('msg_contrast', msg)
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._tweak_colormap(viewer, x, y, 'preview')
elif event.state == 'down':
self._start_x, self._start_y = x, y
if msg:
viewer.onscreen_message(
"Shift and stretch colormap (drag mouse)", delay=1.0)
else:
viewer.onscreen_message(None)
return True | python | def ms_contrast(self, viewer, event, data_x, data_y, msg=True):
"""Shift the colormap by dragging the cursor left or right.
Stretch the colormap by dragging the cursor up or down.
"""
if not self.cancmap:
return True
msg = self.settings.get('msg_contrast', msg)
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._tweak_colormap(viewer, x, y, 'preview')
elif event.state == 'down':
self._start_x, self._start_y = x, y
if msg:
viewer.onscreen_message(
"Shift and stretch colormap (drag mouse)", delay=1.0)
else:
viewer.onscreen_message(None)
return True | [
"def",
"ms_contrast",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
",",
"msg",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"cancmap",
":",
"return",
"True",
"msg",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"'msg... | Shift the colormap by dragging the cursor left or right.
Stretch the colormap by dragging the cursor up or down. | [
"Shift",
"the",
"colormap",
"by",
"dragging",
"the",
"cursor",
"left",
"or",
"right",
".",
"Stretch",
"the",
"colormap",
"by",
"dragging",
"the",
"cursor",
"up",
"or",
"down",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1674-L1694 | train | 24,867 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_contrast_restore | def ms_contrast_restore(self, viewer, event, data_x, data_y, msg=True):
"""An interactive way to restore the colormap contrast settings after
a warp operation.
"""
if self.cancmap and (event.state == 'down'):
self.restore_contrast(viewer, msg=msg)
return True | python | def ms_contrast_restore(self, viewer, event, data_x, data_y, msg=True):
"""An interactive way to restore the colormap contrast settings after
a warp operation.
"""
if self.cancmap and (event.state == 'down'):
self.restore_contrast(viewer, msg=msg)
return True | [
"def",
"ms_contrast_restore",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
",",
"msg",
"=",
"True",
")",
":",
"if",
"self",
".",
"cancmap",
"and",
"(",
"event",
".",
"state",
"==",
"'down'",
")",
":",
"self",
".",
"restore_... | An interactive way to restore the colormap contrast settings after
a warp operation. | [
"An",
"interactive",
"way",
"to",
"restore",
"the",
"colormap",
"contrast",
"settings",
"after",
"a",
"warp",
"operation",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1696-L1702 | train | 24,868 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_cmap_restore | def ms_cmap_restore(self, viewer, event, data_x, data_y, msg=True):
"""An interactive way to restore the colormap settings after
a rotate or invert operation.
"""
if self.cancmap and (event.state == 'down'):
self.restore_colormap(viewer, msg)
return True | python | def ms_cmap_restore(self, viewer, event, data_x, data_y, msg=True):
"""An interactive way to restore the colormap settings after
a rotate or invert operation.
"""
if self.cancmap and (event.state == 'down'):
self.restore_colormap(viewer, msg)
return True | [
"def",
"ms_cmap_restore",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
",",
"msg",
"=",
"True",
")",
":",
"if",
"self",
".",
"cancmap",
"and",
"(",
"event",
".",
"state",
"==",
"'down'",
")",
":",
"self",
".",
"restore_colo... | An interactive way to restore the colormap settings after
a rotate or invert operation. | [
"An",
"interactive",
"way",
"to",
"restore",
"the",
"colormap",
"settings",
"after",
"a",
"rotate",
"or",
"invert",
"operation",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1726-L1732 | train | 24,869 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_pan | def ms_pan(self, viewer, event, data_x, data_y):
"""A 'drag' or proportional pan, where the image is panned by
'dragging the canvas' up or down. The amount of the pan is
proportionate to the length of the drag.
"""
if not self.canpan:
return True
x, y = viewer.get_last_win_xy()
if event.state == 'move':
data_x, data_y = self.get_new_pan(viewer, x, y,
ptype=self._pantype)
viewer.panset_xy(data_x, data_y)
elif event.state == 'down':
self.pan_set_origin(viewer, x, y, data_x, data_y)
self.pan_start(viewer, ptype=2)
else:
self.pan_stop(viewer)
return True | python | def ms_pan(self, viewer, event, data_x, data_y):
"""A 'drag' or proportional pan, where the image is panned by
'dragging the canvas' up or down. The amount of the pan is
proportionate to the length of the drag.
"""
if not self.canpan:
return True
x, y = viewer.get_last_win_xy()
if event.state == 'move':
data_x, data_y = self.get_new_pan(viewer, x, y,
ptype=self._pantype)
viewer.panset_xy(data_x, data_y)
elif event.state == 'down':
self.pan_set_origin(viewer, x, y, data_x, data_y)
self.pan_start(viewer, ptype=2)
else:
self.pan_stop(viewer)
return True | [
"def",
"ms_pan",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
")",
":",
"if",
"not",
"self",
".",
"canpan",
":",
"return",
"True",
"x",
",",
"y",
"=",
"viewer",
".",
"get_last_win_xy",
"(",
")",
"if",
"event",
".",
"state... | A 'drag' or proportional pan, where the image is panned by
'dragging the canvas' up or down. The amount of the pan is
proportionate to the length of the drag. | [
"A",
"drag",
"or",
"proportional",
"pan",
"where",
"the",
"image",
"is",
"panned",
"by",
"dragging",
"the",
"canvas",
"up",
"or",
"down",
".",
"The",
"amount",
"of",
"the",
"pan",
"is",
"proportionate",
"to",
"the",
"length",
"of",
"the",
"drag",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1734-L1754 | train | 24,870 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_cutlo | def ms_cutlo(self, viewer, event, data_x, data_y):
"""An interactive way to set the low cut level.
"""
if not self.cancut:
return True
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._cutlow_xy(viewer, x, y)
elif event.state == 'down':
self._start_x, self._start_y = x, y
self._loval, self._hival = viewer.get_cut_levels()
else:
viewer.onscreen_message(None)
return True | python | def ms_cutlo(self, viewer, event, data_x, data_y):
"""An interactive way to set the low cut level.
"""
if not self.cancut:
return True
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._cutlow_xy(viewer, x, y)
elif event.state == 'down':
self._start_x, self._start_y = x, y
self._loval, self._hival = viewer.get_cut_levels()
else:
viewer.onscreen_message(None)
return True | [
"def",
"ms_cutlo",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
")",
":",
"if",
"not",
"self",
".",
"cancut",
":",
"return",
"True",
"x",
",",
"y",
"=",
"self",
".",
"get_win_xy",
"(",
"viewer",
")",
"if",
"event",
".",
... | An interactive way to set the low cut level. | [
"An",
"interactive",
"way",
"to",
"set",
"the",
"low",
"cut",
"level",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1777-L1794 | train | 24,871 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.ms_cutall | def ms_cutall(self, viewer, event, data_x, data_y):
"""An interactive way to set the low AND high cut levels.
"""
if not self.cancut:
return True
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._cutboth_xy(viewer, x, y)
elif event.state == 'down':
self._start_x, self._start_y = x, y
image = viewer.get_image()
#self._loval, self._hival = viewer.get_cut_levels()
self._loval, self._hival = viewer.autocuts.calc_cut_levels(image)
else:
viewer.onscreen_message(None)
return True | python | def ms_cutall(self, viewer, event, data_x, data_y):
"""An interactive way to set the low AND high cut levels.
"""
if not self.cancut:
return True
x, y = self.get_win_xy(viewer)
if event.state == 'move':
self._cutboth_xy(viewer, x, y)
elif event.state == 'down':
self._start_x, self._start_y = x, y
image = viewer.get_image()
#self._loval, self._hival = viewer.get_cut_levels()
self._loval, self._hival = viewer.autocuts.calc_cut_levels(image)
else:
viewer.onscreen_message(None)
return True | [
"def",
"ms_cutall",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"data_x",
",",
"data_y",
")",
":",
"if",
"not",
"self",
".",
"cancut",
":",
"return",
"True",
"x",
",",
"y",
"=",
"self",
".",
"get_win_xy",
"(",
"viewer",
")",
"if",
"event",
".",
... | An interactive way to set the low AND high cut levels. | [
"An",
"interactive",
"way",
"to",
"set",
"the",
"low",
"AND",
"high",
"cut",
"levels",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1815-L1834 | train | 24,872 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_cuts_coarse | def sc_cuts_coarse(self, viewer, event, msg=True):
"""Adjust cuts interactively by setting the low AND high cut
levels. This function adjusts it coarsely.
"""
if self.cancut:
# adjust the cut by 10% on each end
self._adjust_cuts(viewer, event.direction, 0.1, msg=msg)
return True | python | def sc_cuts_coarse(self, viewer, event, msg=True):
"""Adjust cuts interactively by setting the low AND high cut
levels. This function adjusts it coarsely.
"""
if self.cancut:
# adjust the cut by 10% on each end
self._adjust_cuts(viewer, event.direction, 0.1, msg=msg)
return True | [
"def",
"sc_cuts_coarse",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"if",
"self",
".",
"cancut",
":",
"# adjust the cut by 10% on each end",
"self",
".",
"_adjust_cuts",
"(",
"viewer",
",",
"event",
".",
"direction",
",",
... | Adjust cuts interactively by setting the low AND high cut
levels. This function adjusts it coarsely. | [
"Adjust",
"cuts",
"interactively",
"by",
"setting",
"the",
"low",
"AND",
"high",
"cut",
"levels",
".",
"This",
"function",
"adjusts",
"it",
"coarsely",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1878-L1885 | train | 24,873 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_cuts_alg | def sc_cuts_alg(self, viewer, event, msg=True):
"""Adjust cuts algorithm interactively.
"""
if self.cancut:
direction = self.get_direction(event.direction)
self._cycle_cuts_alg(viewer, msg, direction=direction)
return True | python | def sc_cuts_alg(self, viewer, event, msg=True):
"""Adjust cuts algorithm interactively.
"""
if self.cancut:
direction = self.get_direction(event.direction)
self._cycle_cuts_alg(viewer, msg, direction=direction)
return True | [
"def",
"sc_cuts_alg",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"if",
"self",
".",
"cancut",
":",
"direction",
"=",
"self",
".",
"get_direction",
"(",
"event",
".",
"direction",
")",
"self",
".",
"_cycle_cuts_alg",
"(... | Adjust cuts algorithm interactively. | [
"Adjust",
"cuts",
"algorithm",
"interactively",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1896-L1902 | train | 24,874 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_zoom | def sc_zoom(self, viewer, event, msg=True):
"""Interactively zoom the image by scrolling motion.
This zooms by the zoom steps configured under Preferences.
"""
self._sc_zoom(viewer, event, msg=msg, origin=None)
return True | python | def sc_zoom(self, viewer, event, msg=True):
"""Interactively zoom the image by scrolling motion.
This zooms by the zoom steps configured under Preferences.
"""
self._sc_zoom(viewer, event, msg=msg, origin=None)
return True | [
"def",
"sc_zoom",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"self",
".",
"_sc_zoom",
"(",
"viewer",
",",
"event",
",",
"msg",
"=",
"msg",
",",
"origin",
"=",
"None",
")",
"return",
"True"
] | Interactively zoom the image by scrolling motion.
This zooms by the zoom steps configured under Preferences. | [
"Interactively",
"zoom",
"the",
"image",
"by",
"scrolling",
"motion",
".",
"This",
"zooms",
"by",
"the",
"zoom",
"steps",
"configured",
"under",
"Preferences",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1952-L1957 | train | 24,875 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_zoom_coarse | def sc_zoom_coarse(self, viewer, event, msg=True):
"""Interactively zoom the image by scrolling motion.
This zooms by adjusting the scale in x and y coarsely.
"""
if not self.canzoom:
return True
zoom_accel = self.settings.get('scroll_zoom_acceleration', 1.0)
# change scale by 20%
amount = self._scale_adjust(1.2, event.amount, zoom_accel, max_limit=4.0)
self._scale_image(viewer, event.direction, amount, msg=msg)
return True | python | def sc_zoom_coarse(self, viewer, event, msg=True):
"""Interactively zoom the image by scrolling motion.
This zooms by adjusting the scale in x and y coarsely.
"""
if not self.canzoom:
return True
zoom_accel = self.settings.get('scroll_zoom_acceleration', 1.0)
# change scale by 20%
amount = self._scale_adjust(1.2, event.amount, zoom_accel, max_limit=4.0)
self._scale_image(viewer, event.direction, amount, msg=msg)
return True | [
"def",
"sc_zoom_coarse",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"canzoom",
":",
"return",
"True",
"zoom_accel",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"'scroll_zoom_acceleration'",
"... | Interactively zoom the image by scrolling motion.
This zooms by adjusting the scale in x and y coarsely. | [
"Interactively",
"zoom",
"the",
"image",
"by",
"scrolling",
"motion",
".",
"This",
"zooms",
"by",
"adjusting",
"the",
"scale",
"in",
"x",
"and",
"y",
"coarsely",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1968-L1979 | train | 24,876 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_pan | def sc_pan(self, viewer, event, msg=True):
"""Interactively pan the image by scrolling motion.
"""
if not self.canpan:
return True
# User has "Pan Reverse" preference set?
rev = self.settings.get('pan_reverse', False)
direction = event.direction
if rev:
direction = math.fmod(direction + 180.0, 360.0)
pan_accel = self.settings.get('scroll_pan_acceleration', 1.0)
# Internal factor to adjust the panning speed so that user-adjustable
# scroll_pan_acceleration is normalized to 1.0 for "normal" speed
scr_pan_adj_factor = 1.4142135623730951
amount = (event.amount * scr_pan_adj_factor * pan_accel) / 360.0
self.pan_omni(viewer, direction, amount)
return True | python | def sc_pan(self, viewer, event, msg=True):
"""Interactively pan the image by scrolling motion.
"""
if not self.canpan:
return True
# User has "Pan Reverse" preference set?
rev = self.settings.get('pan_reverse', False)
direction = event.direction
if rev:
direction = math.fmod(direction + 180.0, 360.0)
pan_accel = self.settings.get('scroll_pan_acceleration', 1.0)
# Internal factor to adjust the panning speed so that user-adjustable
# scroll_pan_acceleration is normalized to 1.0 for "normal" speed
scr_pan_adj_factor = 1.4142135623730951
amount = (event.amount * scr_pan_adj_factor * pan_accel) / 360.0
self.pan_omni(viewer, direction, amount)
return True | [
"def",
"sc_pan",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"canpan",
":",
"return",
"True",
"# User has \"Pan Reverse\" preference set?",
"rev",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"... | Interactively pan the image by scrolling motion. | [
"Interactively",
"pan",
"the",
"image",
"by",
"scrolling",
"motion",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1994-L2014 | train | 24,877 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_dist | def sc_dist(self, viewer, event, msg=True):
"""Interactively change the color distribution algorithm
by scrolling.
"""
direction = self.get_direction(event.direction)
self._cycle_dist(viewer, msg, direction=direction)
return True | python | def sc_dist(self, viewer, event, msg=True):
"""Interactively change the color distribution algorithm
by scrolling.
"""
direction = self.get_direction(event.direction)
self._cycle_dist(viewer, msg, direction=direction)
return True | [
"def",
"sc_dist",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"direction",
"=",
"self",
".",
"get_direction",
"(",
"event",
".",
"direction",
")",
"self",
".",
"_cycle_dist",
"(",
"viewer",
",",
"msg",
",",
"direction",... | Interactively change the color distribution algorithm
by scrolling. | [
"Interactively",
"change",
"the",
"color",
"distribution",
"algorithm",
"by",
"scrolling",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L2034-L2040 | train | 24,878 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_cmap | def sc_cmap(self, viewer, event, msg=True):
"""Interactively change the color map by scrolling.
"""
direction = self.get_direction(event.direction)
self._cycle_cmap(viewer, msg, direction=direction)
return True | python | def sc_cmap(self, viewer, event, msg=True):
"""Interactively change the color map by scrolling.
"""
direction = self.get_direction(event.direction)
self._cycle_cmap(viewer, msg, direction=direction)
return True | [
"def",
"sc_cmap",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"direction",
"=",
"self",
".",
"get_direction",
"(",
"event",
".",
"direction",
")",
"self",
".",
"_cycle_cmap",
"(",
"viewer",
",",
"msg",
",",
"direction",... | Interactively change the color map by scrolling. | [
"Interactively",
"change",
"the",
"color",
"map",
"by",
"scrolling",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L2042-L2047 | train | 24,879 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.sc_imap | def sc_imap(self, viewer, event, msg=True):
"""Interactively change the intensity map by scrolling.
"""
direction = self.get_direction(event.direction)
self._cycle_imap(viewer, msg, direction=direction)
return True | python | def sc_imap(self, viewer, event, msg=True):
"""Interactively change the intensity map by scrolling.
"""
direction = self.get_direction(event.direction)
self._cycle_imap(viewer, msg, direction=direction)
return True | [
"def",
"sc_imap",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"direction",
"=",
"self",
".",
"get_direction",
"(",
"event",
".",
"direction",
")",
"self",
".",
"_cycle_imap",
"(",
"viewer",
",",
"msg",
",",
"direction",... | Interactively change the intensity map by scrolling. | [
"Interactively",
"change",
"the",
"intensity",
"map",
"by",
"scrolling",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L2049-L2054 | train | 24,880 |
ejeschke/ginga | ginga/Bindings.py | ImageViewBindings.pa_naxis | def pa_naxis(self, viewer, event, msg=True):
"""Interactively change the slice of the image in a data cube
by pan gesture.
"""
event = self._pa_synth_scroll_event(event)
if event.state != 'move':
return False
# TODO: be able to pick axis
axis = 2
direction = self.get_direction(event.direction)
return self._nav_naxis(viewer, axis, direction, msg=msg) | python | def pa_naxis(self, viewer, event, msg=True):
"""Interactively change the slice of the image in a data cube
by pan gesture.
"""
event = self._pa_synth_scroll_event(event)
if event.state != 'move':
return False
# TODO: be able to pick axis
axis = 2
direction = self.get_direction(event.direction)
return self._nav_naxis(viewer, axis, direction, msg=msg) | [
"def",
"pa_naxis",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"event",
"=",
"self",
".",
"_pa_synth_scroll_event",
"(",
"event",
")",
"if",
"event",
".",
"state",
"!=",
"'move'",
":",
"return",
"False",
"# TODO: be able ... | Interactively change the slice of the image in a data cube
by pan gesture. | [
"Interactively",
"change",
"the",
"slice",
"of",
"the",
"image",
"in",
"a",
"data",
"cube",
"by",
"pan",
"gesture",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L2269-L2281 | train | 24,881 |
ejeschke/ginga | ginga/Bindings.py | BindingMapper.mode_key_down | def mode_key_down(self, viewer, keyname):
"""This method is called when a key is pressed and was not handled
by some other handler with precedence, such as a subcanvas.
"""
# Is this a mode key?
if keyname not in self.mode_map:
if (keyname not in self.mode_tbl) or (self._kbdmode != 'meta'):
# No
return False
bnch = self.mode_tbl[keyname]
else:
bnch = self.mode_map[keyname]
mode_name = bnch.name
self.logger.debug("cur mode='%s' mode pressed='%s'" % (
self._kbdmode, mode_name))
if mode_name == self._kbdmode:
# <== same key was pressed that started the mode we're in
# standard handling is to close the mode when we press the
# key again that started that mode
self.reset_mode(viewer)
return True
if self._delayed_reset:
# <== this shouldn't happen, but put here to reset handling
# of delayed_reset just in case (see cursor up handling)
self._delayed_reset = False
return True
if ((self._kbdmode in (None, 'meta')) or
(self._kbdmode_type != 'locked') or (mode_name == 'meta')):
if self._kbdmode is not None:
self.reset_mode(viewer)
# activate this mode
if self._kbdmode in (None, 'meta'):
mode_type = bnch.type
if mode_type is None:
mode_type = self._kbdmode_type_default
self.set_mode(mode_name, mode_type)
if bnch.msg is not None:
viewer.onscreen_message(bnch.msg)
return True
return False | python | def mode_key_down(self, viewer, keyname):
"""This method is called when a key is pressed and was not handled
by some other handler with precedence, such as a subcanvas.
"""
# Is this a mode key?
if keyname not in self.mode_map:
if (keyname not in self.mode_tbl) or (self._kbdmode != 'meta'):
# No
return False
bnch = self.mode_tbl[keyname]
else:
bnch = self.mode_map[keyname]
mode_name = bnch.name
self.logger.debug("cur mode='%s' mode pressed='%s'" % (
self._kbdmode, mode_name))
if mode_name == self._kbdmode:
# <== same key was pressed that started the mode we're in
# standard handling is to close the mode when we press the
# key again that started that mode
self.reset_mode(viewer)
return True
if self._delayed_reset:
# <== this shouldn't happen, but put here to reset handling
# of delayed_reset just in case (see cursor up handling)
self._delayed_reset = False
return True
if ((self._kbdmode in (None, 'meta')) or
(self._kbdmode_type != 'locked') or (mode_name == 'meta')):
if self._kbdmode is not None:
self.reset_mode(viewer)
# activate this mode
if self._kbdmode in (None, 'meta'):
mode_type = bnch.type
if mode_type is None:
mode_type = self._kbdmode_type_default
self.set_mode(mode_name, mode_type)
if bnch.msg is not None:
viewer.onscreen_message(bnch.msg)
return True
return False | [
"def",
"mode_key_down",
"(",
"self",
",",
"viewer",
",",
"keyname",
")",
":",
"# Is this a mode key?",
"if",
"keyname",
"not",
"in",
"self",
".",
"mode_map",
":",
"if",
"(",
"keyname",
"not",
"in",
"self",
".",
"mode_tbl",
")",
"or",
"(",
"self",
".",
... | This method is called when a key is pressed and was not handled
by some other handler with precedence, such as a subcanvas. | [
"This",
"method",
"is",
"called",
"when",
"a",
"key",
"is",
"pressed",
"and",
"was",
"not",
"handled",
"by",
"some",
"other",
"handler",
"with",
"precedence",
"such",
"as",
"a",
"subcanvas",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L2658-L2704 | train | 24,882 |
ejeschke/ginga | ginga/Bindings.py | BindingMapper.mode_key_up | def mode_key_up(self, viewer, keyname):
"""This method is called when a key is pressed in a mode and was
not handled by some other handler with precedence, such as a
subcanvas.
"""
# Is this a mode key?
if keyname not in self.mode_map:
# <== no
return False
bnch = self.mode_map[keyname]
if self._kbdmode == bnch.name:
# <-- the current mode key is being released
if bnch.type == 'held':
if self._button == 0:
# if no button is being held, then reset mode
self.reset_mode(viewer)
else:
self._delayed_reset = True
return True
return False | python | def mode_key_up(self, viewer, keyname):
"""This method is called when a key is pressed in a mode and was
not handled by some other handler with precedence, such as a
subcanvas.
"""
# Is this a mode key?
if keyname not in self.mode_map:
# <== no
return False
bnch = self.mode_map[keyname]
if self._kbdmode == bnch.name:
# <-- the current mode key is being released
if bnch.type == 'held':
if self._button == 0:
# if no button is being held, then reset mode
self.reset_mode(viewer)
else:
self._delayed_reset = True
return True
return False | [
"def",
"mode_key_up",
"(",
"self",
",",
"viewer",
",",
"keyname",
")",
":",
"# Is this a mode key?",
"if",
"keyname",
"not",
"in",
"self",
".",
"mode_map",
":",
"# <== no",
"return",
"False",
"bnch",
"=",
"self",
".",
"mode_map",
"[",
"keyname",
"]",
"if",... | This method is called when a key is pressed in a mode and was
not handled by some other handler with precedence, such as a
subcanvas. | [
"This",
"method",
"is",
"called",
"when",
"a",
"key",
"is",
"pressed",
"in",
"a",
"mode",
"and",
"was",
"not",
"handled",
"by",
"some",
"other",
"handler",
"with",
"precedence",
"such",
"as",
"a",
"subcanvas",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L2706-L2727 | train | 24,883 |
ejeschke/ginga | ginga/util/bezier.py | get_4pt_bezier | def get_4pt_bezier(steps, points):
"""Gets a series of bezier curve points with 1 set of 4
control points."""
for i in range(steps):
t = i / float(steps)
xloc = (math.pow(1 - t, 3) * points[0][0] +
3 * t * math.pow(1 - t, 2) * points[1][0] +
3 * (1 - t) * math.pow(t, 2) * points[2][0] +
math.pow(t, 3) * points[3][0])
yloc = (math.pow(1 - t, 3) * points[0][1] +
3 * t * math.pow(1 - t, 2) * points[1][1] +
3 * (1 - t) * math.pow(t, 2) * points[2][1] +
math.pow(t, 3) * points[3][1])
yield (xloc, yloc) | python | def get_4pt_bezier(steps, points):
"""Gets a series of bezier curve points with 1 set of 4
control points."""
for i in range(steps):
t = i / float(steps)
xloc = (math.pow(1 - t, 3) * points[0][0] +
3 * t * math.pow(1 - t, 2) * points[1][0] +
3 * (1 - t) * math.pow(t, 2) * points[2][0] +
math.pow(t, 3) * points[3][0])
yloc = (math.pow(1 - t, 3) * points[0][1] +
3 * t * math.pow(1 - t, 2) * points[1][1] +
3 * (1 - t) * math.pow(t, 2) * points[2][1] +
math.pow(t, 3) * points[3][1])
yield (xloc, yloc) | [
"def",
"get_4pt_bezier",
"(",
"steps",
",",
"points",
")",
":",
"for",
"i",
"in",
"range",
"(",
"steps",
")",
":",
"t",
"=",
"i",
"/",
"float",
"(",
"steps",
")",
"xloc",
"=",
"(",
"math",
".",
"pow",
"(",
"1",
"-",
"t",
",",
"3",
")",
"*",
... | Gets a series of bezier curve points with 1 set of 4
control points. | [
"Gets",
"a",
"series",
"of",
"bezier",
"curve",
"points",
"with",
"1",
"set",
"of",
"4",
"control",
"points",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/bezier.py#L19-L34 | train | 24,884 |
ejeschke/ginga | ginga/util/bezier.py | get_bezier | def get_bezier(steps, points):
"""Gets a series of bezier curve points with any number of sets
of 4 control points."""
res = []
num_pts = len(points)
for i in range(0, num_pts + 1, 3):
if i + 4 < num_pts + 1:
res.extend(list(get_4pt_bezier(steps, points[i:i + 4])))
return res | python | def get_bezier(steps, points):
"""Gets a series of bezier curve points with any number of sets
of 4 control points."""
res = []
num_pts = len(points)
for i in range(0, num_pts + 1, 3):
if i + 4 < num_pts + 1:
res.extend(list(get_4pt_bezier(steps, points[i:i + 4])))
return res | [
"def",
"get_bezier",
"(",
"steps",
",",
"points",
")",
":",
"res",
"=",
"[",
"]",
"num_pts",
"=",
"len",
"(",
"points",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"num_pts",
"+",
"1",
",",
"3",
")",
":",
"if",
"i",
"+",
"4",
"<",
"num_pts... | Gets a series of bezier curve points with any number of sets
of 4 control points. | [
"Gets",
"a",
"series",
"of",
"bezier",
"curve",
"points",
"with",
"any",
"number",
"of",
"sets",
"of",
"4",
"control",
"points",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/bezier.py#L37-L45 | train | 24,885 |
ejeschke/ginga | ginga/util/bezier.py | get_bezier_ellipse | def get_bezier_ellipse(x, y, xradius, yradius, kappa=0.5522848):
"""Get a set of 12 bezier control points necessary to form an
ellipse."""
xs, ys = x - xradius, y - yradius
ox, oy = xradius * kappa, yradius * kappa
xe, ye = x + xradius, y + yradius
pts = [(xs, y),
(xs, y - oy), (x - ox, ys), (x, ys),
(x + ox, ys), (xe, y - oy), (xe, y),
(xe, y + oy), (x + ox, ye), (x, ye),
(x - ox, ye), (xs, y + oy), (xs, y)]
return pts | python | def get_bezier_ellipse(x, y, xradius, yradius, kappa=0.5522848):
"""Get a set of 12 bezier control points necessary to form an
ellipse."""
xs, ys = x - xradius, y - yradius
ox, oy = xradius * kappa, yradius * kappa
xe, ye = x + xradius, y + yradius
pts = [(xs, y),
(xs, y - oy), (x - ox, ys), (x, ys),
(x + ox, ys), (xe, y - oy), (xe, y),
(xe, y + oy), (x + ox, ye), (x, ye),
(x - ox, ye), (xs, y + oy), (xs, y)]
return pts | [
"def",
"get_bezier_ellipse",
"(",
"x",
",",
"y",
",",
"xradius",
",",
"yradius",
",",
"kappa",
"=",
"0.5522848",
")",
":",
"xs",
",",
"ys",
"=",
"x",
"-",
"xradius",
",",
"y",
"-",
"yradius",
"ox",
",",
"oy",
"=",
"xradius",
"*",
"kappa",
",",
"y... | Get a set of 12 bezier control points necessary to form an
ellipse. | [
"Get",
"a",
"set",
"of",
"12",
"bezier",
"control",
"points",
"necessary",
"to",
"form",
"an",
"ellipse",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/bezier.py#L48-L61 | train | 24,886 |
ejeschke/ginga | ginga/rv/plugins/Preferences.py | Preferences.set_cmap_cb | def set_cmap_cb(self, w, index):
"""This callback is invoked when the user selects a new color
map from the preferences pane."""
name = cmap.get_names()[index]
self.t_.set(color_map=name) | python | def set_cmap_cb(self, w, index):
"""This callback is invoked when the user selects a new color
map from the preferences pane."""
name = cmap.get_names()[index]
self.t_.set(color_map=name) | [
"def",
"set_cmap_cb",
"(",
"self",
",",
"w",
",",
"index",
")",
":",
"name",
"=",
"cmap",
".",
"get_names",
"(",
")",
"[",
"index",
"]",
"self",
".",
"t_",
".",
"set",
"(",
"color_map",
"=",
"name",
")"
] | This callback is invoked when the user selects a new color
map from the preferences pane. | [
"This",
"callback",
"is",
"invoked",
"when",
"the",
"user",
"selects",
"a",
"new",
"color",
"map",
"from",
"the",
"preferences",
"pane",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Preferences.py#L980-L984 | train | 24,887 |
ejeschke/ginga | ginga/rv/plugins/Preferences.py | Preferences.set_imap_cb | def set_imap_cb(self, w, index):
"""This callback is invoked when the user selects a new intensity
map from the preferences pane."""
name = imap.get_names()[index]
self.t_.set(intensity_map=name) | python | def set_imap_cb(self, w, index):
"""This callback is invoked when the user selects a new intensity
map from the preferences pane."""
name = imap.get_names()[index]
self.t_.set(intensity_map=name) | [
"def",
"set_imap_cb",
"(",
"self",
",",
"w",
",",
"index",
")",
":",
"name",
"=",
"imap",
".",
"get_names",
"(",
")",
"[",
"index",
"]",
"self",
".",
"t_",
".",
"set",
"(",
"intensity_map",
"=",
"name",
")"
] | This callback is invoked when the user selects a new intensity
map from the preferences pane. | [
"This",
"callback",
"is",
"invoked",
"when",
"the",
"user",
"selects",
"a",
"new",
"intensity",
"map",
"from",
"the",
"preferences",
"pane",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Preferences.py#L986-L990 | train | 24,888 |
ejeschke/ginga | ginga/rv/plugins/Preferences.py | Preferences.set_calg_cb | def set_calg_cb(self, w, index):
"""This callback is invoked when the user selects a new color
hashing algorithm from the preferences pane."""
#index = w.get_index()
name = self.calg_names[index]
self.t_.set(color_algorithm=name) | python | def set_calg_cb(self, w, index):
"""This callback is invoked when the user selects a new color
hashing algorithm from the preferences pane."""
#index = w.get_index()
name = self.calg_names[index]
self.t_.set(color_algorithm=name) | [
"def",
"set_calg_cb",
"(",
"self",
",",
"w",
",",
"index",
")",
":",
"#index = w.get_index()",
"name",
"=",
"self",
".",
"calg_names",
"[",
"index",
"]",
"self",
".",
"t_",
".",
"set",
"(",
"color_algorithm",
"=",
"name",
")"
] | This callback is invoked when the user selects a new color
hashing algorithm from the preferences pane. | [
"This",
"callback",
"is",
"invoked",
"when",
"the",
"user",
"selects",
"a",
"new",
"color",
"hashing",
"algorithm",
"from",
"the",
"preferences",
"pane",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Preferences.py#L992-L997 | train | 24,889 |
ejeschke/ginga | ginga/rv/plugins/Preferences.py | Preferences.autocut_params_changed_cb | def autocut_params_changed_cb(self, paramObj, ac_obj):
"""This callback is called when the user changes the attributes of
an object via the paramSet.
"""
args, kwdargs = paramObj.get_params()
params = list(kwdargs.items())
self.t_.set(autocut_params=params) | python | def autocut_params_changed_cb(self, paramObj, ac_obj):
"""This callback is called when the user changes the attributes of
an object via the paramSet.
"""
args, kwdargs = paramObj.get_params()
params = list(kwdargs.items())
self.t_.set(autocut_params=params) | [
"def",
"autocut_params_changed_cb",
"(",
"self",
",",
"paramObj",
",",
"ac_obj",
")",
":",
"args",
",",
"kwdargs",
"=",
"paramObj",
".",
"get_params",
"(",
")",
"params",
"=",
"list",
"(",
"kwdargs",
".",
"items",
"(",
")",
")",
"self",
".",
"t_",
".",... | This callback is called when the user changes the attributes of
an object via the paramSet. | [
"This",
"callback",
"is",
"called",
"when",
"the",
"user",
"changes",
"the",
"attributes",
"of",
"an",
"object",
"via",
"the",
"paramSet",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Preferences.py#L1182-L1188 | train | 24,890 |
ejeschke/ginga | ginga/rv/plugins/Preferences.py | Preferences.set_sort_cb | def set_sort_cb(self, w, index):
"""This callback is invoked when the user selects a new sort order
from the preferences pane."""
name = self.sort_options[index]
self.t_.set(sort_order=name) | python | def set_sort_cb(self, w, index):
"""This callback is invoked when the user selects a new sort order
from the preferences pane."""
name = self.sort_options[index]
self.t_.set(sort_order=name) | [
"def",
"set_sort_cb",
"(",
"self",
",",
"w",
",",
"index",
")",
":",
"name",
"=",
"self",
".",
"sort_options",
"[",
"index",
"]",
"self",
".",
"t_",
".",
"set",
"(",
"sort_order",
"=",
"name",
")"
] | This callback is invoked when the user selects a new sort order
from the preferences pane. | [
"This",
"callback",
"is",
"invoked",
"when",
"the",
"user",
"selects",
"a",
"new",
"sort",
"order",
"from",
"the",
"preferences",
"pane",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Preferences.py#L1254-L1258 | train | 24,891 |
ejeschke/ginga | ginga/rv/plugins/Preferences.py | Preferences.set_scrollbars_cb | def set_scrollbars_cb(self, w, tf):
"""This callback is invoked when the user checks the 'Use Scrollbars'
box in the preferences pane."""
scrollbars = 'on' if tf else 'off'
self.t_.set(scrollbars=scrollbars) | python | def set_scrollbars_cb(self, w, tf):
"""This callback is invoked when the user checks the 'Use Scrollbars'
box in the preferences pane."""
scrollbars = 'on' if tf else 'off'
self.t_.set(scrollbars=scrollbars) | [
"def",
"set_scrollbars_cb",
"(",
"self",
",",
"w",
",",
"tf",
")",
":",
"scrollbars",
"=",
"'on'",
"if",
"tf",
"else",
"'off'",
"self",
".",
"t_",
".",
"set",
"(",
"scrollbars",
"=",
"scrollbars",
")"
] | This callback is invoked when the user checks the 'Use Scrollbars'
box in the preferences pane. | [
"This",
"callback",
"is",
"invoked",
"when",
"the",
"user",
"checks",
"the",
"Use",
"Scrollbars",
"box",
"in",
"the",
"preferences",
"pane",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Preferences.py#L1265-L1269 | train | 24,892 |
ejeschke/ginga | ginga/rv/plugins/Info.py | Info.zoomset_cb | def zoomset_cb(self, setting, value, channel):
"""This callback is called when the main window is zoomed.
"""
if not self.gui_up:
return
info = channel.extdata._info_info
if info is None:
return
#scale_x, scale_y = fitsimage.get_scale_xy()
scale_x, scale_y = value
# Set text showing zoom factor (1X, 2X, etc.)
if scale_x == scale_y:
text = self.fv.scale2text(scale_x)
else:
textx = self.fv.scale2text(scale_x)
texty = self.fv.scale2text(scale_y)
text = "X: %s Y: %s" % (textx, texty)
info.winfo.zoom.set_text(text) | python | def zoomset_cb(self, setting, value, channel):
"""This callback is called when the main window is zoomed.
"""
if not self.gui_up:
return
info = channel.extdata._info_info
if info is None:
return
#scale_x, scale_y = fitsimage.get_scale_xy()
scale_x, scale_y = value
# Set text showing zoom factor (1X, 2X, etc.)
if scale_x == scale_y:
text = self.fv.scale2text(scale_x)
else:
textx = self.fv.scale2text(scale_x)
texty = self.fv.scale2text(scale_y)
text = "X: %s Y: %s" % (textx, texty)
info.winfo.zoom.set_text(text) | [
"def",
"zoomset_cb",
"(",
"self",
",",
"setting",
",",
"value",
",",
"channel",
")",
":",
"if",
"not",
"self",
".",
"gui_up",
":",
"return",
"info",
"=",
"channel",
".",
"extdata",
".",
"_info_info",
"if",
"info",
"is",
"None",
":",
"return",
"#scale_x... | This callback is called when the main window is zoomed. | [
"This",
"callback",
"is",
"called",
"when",
"the",
"main",
"window",
"is",
"zoomed",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Info.py#L319-L337 | train | 24,893 |
ejeschke/ginga | ginga/rv/plugins/MultiDim.py | MultiDim.redo | def redo(self):
"""Called when an image is set in the channel."""
image = self.channel.get_current_image()
if image is None:
return True
path = image.get('path', None)
if path is None:
self.fv.show_error(
"Cannot open image: no value for metadata key 'path'")
return
# TODO: How to properly reset GUI components?
# They are still showing info from prev FITS.
# No-op for ASDF
if path.endswith('asdf'):
return True
if path != self.img_path:
# <-- New file is being looked at
self.img_path = path
# close previous file opener, if any
if self.file_obj is not None:
try:
self.file_obj.close()
except Exception:
pass
self.file_obj = io_fits.get_fitsloader(logger=self.logger)
# TODO: specify 'readonly' somehow?
self.file_obj.open_file(path)
upper = len(self.file_obj) - 1
self.prep_hdu_menu(self.w.hdu, self.file_obj.hdu_info)
self.num_hdu = upper
self.logger.debug("there are %d hdus" % (upper + 1))
self.w.numhdu.set_text("%d" % (upper + 1))
self.w.hdu.set_enabled(len(self.file_obj) > 0)
name = image.get('name', iohelper.name_image_from_path(path))
idx = image.get('idx', None)
# remove index designation from root of name, if any
match = re.match(r'^(.+)\[(.+)\]$', name)
if match:
name = match.group(1)
self.name_pfx = name
htype = None
if idx is not None:
# set the HDU in the drop down if known
info = self.file_obj.hdu_db.get(idx, None)
if info is not None:
htype = info.htype.lower()
toc_ent = self._toc_fmt % info
self.w.hdu.show_text(toc_ent)
# rebuild the NAXIS controls, if necessary
# No two images in the same channel can have the same name.
# Here we keep track of the name to decide if we need to rebuild
if self.img_name != name:
self.img_name = name
dims = [0, 0]
data = image.get_data()
if data is None:
# <- empty data part to this HDU
self.logger.warning("Empty data part in HDU %s" % (str(idx)))
elif htype in ('bintablehdu', 'tablehdu',):
pass
elif htype not in ('imagehdu', 'primaryhdu', 'compimagehdu'):
self.logger.warning("HDU %s is not an image (%s)" % (
str(idx), htype))
else:
mddata = image.get_mddata()
if mddata is not None:
dims = list(mddata.shape)
dims.reverse()
self.build_naxis(dims, image) | python | def redo(self):
"""Called when an image is set in the channel."""
image = self.channel.get_current_image()
if image is None:
return True
path = image.get('path', None)
if path is None:
self.fv.show_error(
"Cannot open image: no value for metadata key 'path'")
return
# TODO: How to properly reset GUI components?
# They are still showing info from prev FITS.
# No-op for ASDF
if path.endswith('asdf'):
return True
if path != self.img_path:
# <-- New file is being looked at
self.img_path = path
# close previous file opener, if any
if self.file_obj is not None:
try:
self.file_obj.close()
except Exception:
pass
self.file_obj = io_fits.get_fitsloader(logger=self.logger)
# TODO: specify 'readonly' somehow?
self.file_obj.open_file(path)
upper = len(self.file_obj) - 1
self.prep_hdu_menu(self.w.hdu, self.file_obj.hdu_info)
self.num_hdu = upper
self.logger.debug("there are %d hdus" % (upper + 1))
self.w.numhdu.set_text("%d" % (upper + 1))
self.w.hdu.set_enabled(len(self.file_obj) > 0)
name = image.get('name', iohelper.name_image_from_path(path))
idx = image.get('idx', None)
# remove index designation from root of name, if any
match = re.match(r'^(.+)\[(.+)\]$', name)
if match:
name = match.group(1)
self.name_pfx = name
htype = None
if idx is not None:
# set the HDU in the drop down if known
info = self.file_obj.hdu_db.get(idx, None)
if info is not None:
htype = info.htype.lower()
toc_ent = self._toc_fmt % info
self.w.hdu.show_text(toc_ent)
# rebuild the NAXIS controls, if necessary
# No two images in the same channel can have the same name.
# Here we keep track of the name to decide if we need to rebuild
if self.img_name != name:
self.img_name = name
dims = [0, 0]
data = image.get_data()
if data is None:
# <- empty data part to this HDU
self.logger.warning("Empty data part in HDU %s" % (str(idx)))
elif htype in ('bintablehdu', 'tablehdu',):
pass
elif htype not in ('imagehdu', 'primaryhdu', 'compimagehdu'):
self.logger.warning("HDU %s is not an image (%s)" % (
str(idx), htype))
else:
mddata = image.get_mddata()
if mddata is not None:
dims = list(mddata.shape)
dims.reverse()
self.build_naxis(dims, image) | [
"def",
"redo",
"(",
"self",
")",
":",
"image",
"=",
"self",
".",
"channel",
".",
"get_current_image",
"(",
")",
"if",
"image",
"is",
"None",
":",
"return",
"True",
"path",
"=",
"image",
".",
"get",
"(",
"'path'",
",",
"None",
")",
"if",
"path",
"is... | Called when an image is set in the channel. | [
"Called",
"when",
"an",
"image",
"is",
"set",
"in",
"the",
"channel",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/MultiDim.py#L588-L671 | train | 24,894 |
ejeschke/ginga | ginga/trcalc.py | reorder_image | def reorder_image(dst_order, src_arr, src_order):
"""Reorder src_arr, with order of color planes in src_order, as
dst_order.
"""
depth = src_arr.shape[2]
if depth != len(src_order):
raise ValueError("src_order (%s) does not match array depth (%d)" % (
src_order, depth))
bands = []
if dst_order == src_order:
return np.ascontiguousarray(src_arr)
elif 'A' not in dst_order or 'A' in src_order:
# <-- we don't have to add an alpha plane, just create a new view
idx = np.array([src_order.index(c) for c in dst_order])
return np.ascontiguousarray(src_arr[..., idx])
else:
# <-- dst order requires missing alpha channel
indexes = [src_order.index(c) for c in dst_order.replace('A', '')]
bands = [src_arr[..., idx, np.newaxis] for idx in indexes]
ht, wd = src_arr.shape[:2]
dst_type = src_arr.dtype
dst_max_val = np.iinfo(dst_type).max
alpha = np.full((ht, wd, 1), dst_max_val, dtype=dst_type)
bands.insert(dst_order.index('A'), alpha)
return np.concatenate(bands, axis=-1) | python | def reorder_image(dst_order, src_arr, src_order):
"""Reorder src_arr, with order of color planes in src_order, as
dst_order.
"""
depth = src_arr.shape[2]
if depth != len(src_order):
raise ValueError("src_order (%s) does not match array depth (%d)" % (
src_order, depth))
bands = []
if dst_order == src_order:
return np.ascontiguousarray(src_arr)
elif 'A' not in dst_order or 'A' in src_order:
# <-- we don't have to add an alpha plane, just create a new view
idx = np.array([src_order.index(c) for c in dst_order])
return np.ascontiguousarray(src_arr[..., idx])
else:
# <-- dst order requires missing alpha channel
indexes = [src_order.index(c) for c in dst_order.replace('A', '')]
bands = [src_arr[..., idx, np.newaxis] for idx in indexes]
ht, wd = src_arr.shape[:2]
dst_type = src_arr.dtype
dst_max_val = np.iinfo(dst_type).max
alpha = np.full((ht, wd, 1), dst_max_val, dtype=dst_type)
bands.insert(dst_order.index('A'), alpha)
return np.concatenate(bands, axis=-1) | [
"def",
"reorder_image",
"(",
"dst_order",
",",
"src_arr",
",",
"src_order",
")",
":",
"depth",
"=",
"src_arr",
".",
"shape",
"[",
"2",
"]",
"if",
"depth",
"!=",
"len",
"(",
"src_order",
")",
":",
"raise",
"ValueError",
"(",
"\"src_order (%s) does not match a... | Reorder src_arr, with order of color planes in src_order, as
dst_order. | [
"Reorder",
"src_arr",
"with",
"order",
"of",
"color",
"planes",
"in",
"src_order",
"as",
"dst_order",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/trcalc.py#L845-L873 | train | 24,895 |
ejeschke/ginga | ginga/trcalc.py | strip_z | def strip_z(pts):
"""Strips a Z component from `pts` if it is present."""
pts = np.asarray(pts)
if pts.shape[-1] > 2:
pts = np.asarray((pts.T[0], pts.T[1])).T
return pts | python | def strip_z(pts):
"""Strips a Z component from `pts` if it is present."""
pts = np.asarray(pts)
if pts.shape[-1] > 2:
pts = np.asarray((pts.T[0], pts.T[1])).T
return pts | [
"def",
"strip_z",
"(",
"pts",
")",
":",
"pts",
"=",
"np",
".",
"asarray",
"(",
"pts",
")",
"if",
"pts",
".",
"shape",
"[",
"-",
"1",
"]",
">",
"2",
":",
"pts",
"=",
"np",
".",
"asarray",
"(",
"(",
"pts",
".",
"T",
"[",
"0",
"]",
",",
"pts... | Strips a Z component from `pts` if it is present. | [
"Strips",
"a",
"Z",
"component",
"from",
"pts",
"if",
"it",
"is",
"present",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/trcalc.py#L876-L881 | train | 24,896 |
ejeschke/ginga | ginga/trcalc.py | get_bounds | def get_bounds(pts):
"""Return the minimum point and maximum point bounding a
set of points."""
pts_t = np.asarray(pts).T
return np.asarray(([np.min(_pts) for _pts in pts_t],
[np.max(_pts) for _pts in pts_t])) | python | def get_bounds(pts):
"""Return the minimum point and maximum point bounding a
set of points."""
pts_t = np.asarray(pts).T
return np.asarray(([np.min(_pts) for _pts in pts_t],
[np.max(_pts) for _pts in pts_t])) | [
"def",
"get_bounds",
"(",
"pts",
")",
":",
"pts_t",
"=",
"np",
".",
"asarray",
"(",
"pts",
")",
".",
"T",
"return",
"np",
".",
"asarray",
"(",
"(",
"[",
"np",
".",
"min",
"(",
"_pts",
")",
"for",
"_pts",
"in",
"pts_t",
"]",
",",
"[",
"np",
".... | Return the minimum point and maximum point bounding a
set of points. | [
"Return",
"the",
"minimum",
"point",
"and",
"maximum",
"point",
"bounding",
"a",
"set",
"of",
"points",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/trcalc.py#L896-L901 | train | 24,897 |
ejeschke/ginga | ginga/util/toolbox.py | trim_prefix | def trim_prefix(text, nchr):
"""Trim characters off of the beginnings of text lines.
Parameters
----------
text : str
The text to be trimmed, with newlines (\n) separating lines
nchr: int
The number of spaces to trim off the beginning of a line if
it starts with that many spaces
Returns
-------
text : str
The trimmed text
"""
res = []
for line in text.split('\n'):
if line.startswith(' ' * nchr):
line = line[nchr:]
res.append(line)
return '\n'.join(res) | python | def trim_prefix(text, nchr):
"""Trim characters off of the beginnings of text lines.
Parameters
----------
text : str
The text to be trimmed, with newlines (\n) separating lines
nchr: int
The number of spaces to trim off the beginning of a line if
it starts with that many spaces
Returns
-------
text : str
The trimmed text
"""
res = []
for line in text.split('\n'):
if line.startswith(' ' * nchr):
line = line[nchr:]
res.append(line)
return '\n'.join(res) | [
"def",
"trim_prefix",
"(",
"text",
",",
"nchr",
")",
":",
"res",
"=",
"[",
"]",
"for",
"line",
"in",
"text",
".",
"split",
"(",
"'\\n'",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"' '",
"*",
"nchr",
")",
":",
"line",
"=",
"line",
"[",
"nc... | Trim characters off of the beginnings of text lines.
Parameters
----------
text : str
The text to be trimmed, with newlines (\n) separating lines
nchr: int
The number of spaces to trim off the beginning of a line if
it starts with that many spaces
Returns
-------
text : str
The trimmed text | [
"Trim",
"characters",
"off",
"of",
"the",
"beginnings",
"of",
"text",
"lines",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/toolbox.py#L107-L130 | train | 24,898 |
ejeschke/ginga | ginga/mockw/ImageViewMock.py | ImageViewMock._get_color | def _get_color(self, r, g, b):
"""Convert red, green and blue values specified in floats with
range 0-1 to whatever the native widget color object is.
"""
clr = (r, g, b)
return clr | python | def _get_color(self, r, g, b):
"""Convert red, green and blue values specified in floats with
range 0-1 to whatever the native widget color object is.
"""
clr = (r, g, b)
return clr | [
"def",
"_get_color",
"(",
"self",
",",
"r",
",",
"g",
",",
"b",
")",
":",
"clr",
"=",
"(",
"r",
",",
"g",
",",
"b",
")",
"return",
"clr"
] | Convert red, green and blue values specified in floats with
range 0-1 to whatever the native widget color object is. | [
"Convert",
"red",
"green",
"and",
"blue",
"values",
"specified",
"in",
"floats",
"with",
"range",
"0",
"-",
"1",
"to",
"whatever",
"the",
"native",
"widget",
"color",
"object",
"is",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/mockw/ImageViewMock.py#L191-L196 | train | 24,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.