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 list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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]
... | 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]
... | [
"def",
"set_naxispath",
"(",
"self",
",",
"naxispath",
")",
":",
"revnaxis",
"=",
"list",
"(",
"naxispath",
")",
"revnaxis",
".",
"reverse",
"(",
")",
"view",
"=",
"tuple",
"(",
"revnaxis",
"+",
"[",
"slice",
"(",
"None",
")",
",",
"slice",
"(",
"Non... | 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 |
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... | 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... | [
"def",
"get_keyword",
"(",
"self",
",",
"kwd",
",",
"*",
"args",
")",
":",
"try",
":",
"kwds",
"=",
"self",
".",
"get_header",
"(",
")",
"return",
"kwds",
"[",
"kwd",
"]",
"except",
"KeyError",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
... | 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 |
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()
heade... | 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()
heade... | [
"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",
"=",
"NDDa... | 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 |
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(... | 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(... | [
"def",
"as_hdu",
"(",
"self",
")",
":",
"\"Return a version of ourself as an astropy.io.fits.PrimaryHDU object\"",
"from",
"astropy",
".",
"io",
"import",
"fits",
"ahdr",
"=",
"self",
".",
"get_header",
"(",
")",
"header",
"=",
"fits",
".",
"Header",
"(",
"ahdr",
... | 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 |
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 |
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 |
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 |
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(mi... | 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(mi... | [
"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 |
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(... | 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(... | [
"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 |
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, ... | 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, ... | [
"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 |
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 contai... | 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 contai... | [
"def",
"get_relative_orientation",
"(",
"image",
",",
"ref_image",
")",
":",
"header",
"=",
"ref_image",
".",
"get_header",
"(",
")",
"(",
"(",
"xrot_ref",
",",
"yrot_ref",
")",
",",
"(",
"cdelt1_ref",
",",
"cdelt2_ref",
")",
")",
"=",
"get_xy_rotation_and_s... | 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 rela... | [
"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 |
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)
... | 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)
... | [
"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 |
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 |
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)
... | 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)
... | [
"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 |
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 + ... | 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 + ... | [
"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 |
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",
")",
":",
"lon_deg",
"=",
"hmsStrToDeg",
"(",
"lon",
")",
"else",
":",
"lon_deg",
"=",
"float",
"(",
"lon",
")",
"return",
... | Convert longitude to degrees. | [
"Convert",
"longitude",
"to",
"degrees",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L646-L653 | train |
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",
")",
":",
"lat_deg",
"=",
"dmsStrToDeg",
"(",
"lat",
")",
"else",
":",
"lat_deg",
"=",
"float",
"(",
"lat",
")",
"return",
... | Convert latitude to degrees. | [
"Convert",
"latitude",
"to",
"degrees",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L656-L663 | train |
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=x... | 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=x... | [
"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 |
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 filena... | 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 filena... | [
"def",
"add_font",
"(",
"font_file",
",",
"font_name",
"=",
"None",
")",
":",
"global",
"font_dir",
"if",
"font_name",
"is",
"None",
":",
"dirname",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"font_file",
")",
"font_name",
",",
"ext",
... | 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 |
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... | 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... | [
"def",
"have_font",
"(",
"font_name",
")",
":",
"if",
"font_name",
"in",
"font_dir",
":",
"return",
"True",
"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 |
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 |
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(... | 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(... | [
"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 |
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.
"""
... | 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.
"""
... | [
"def",
"cmd_load",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"ch",
"=",
"kwargs",
".",
"get",
"(",
"'ch'",
",",
"None",
")",
"for",
"item",
"in",
"args",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"item",
")",
"self",
".",... | 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 |
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.
"""
vie... | 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.
"""
vie... | [
"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 |
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
... | 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
... | [
"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 |
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/chann... | 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/chann... | [
"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 |
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 |
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.
... | 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.
... | [
"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 |
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 cur... | 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 cur... | [
"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 |
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:
se... | 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:
se... | [
"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 |
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(... | 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(... | [
"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 |
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.
"""
... | 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.
"""
... | [
"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 |
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 v... | 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 v... | [
"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 |
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... | 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... | [
"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 |
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 |
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 ... | 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 ... | [
"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 |
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 |
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)
... | 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)
... | [
"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 |
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 |
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:
... | 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:
... | [
"def",
"remove",
"(",
"self",
",",
"timer",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"timer",
"in",
"self",
".",
"timers",
":",
"self",
".",
"_remove",
"(",
"timer",
")",
"return",
"False",
"else",
":",
"return",
"True"
] | 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 |
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 ... | 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 ... | [
"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 |
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.object... | 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.object... | [
"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 |
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)... | 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)... | [
"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 |
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 |
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 |
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 |
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 |
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'):
... | 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'):
... | [
"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 |
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.ad... | 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.ad... | [
"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 |
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]
... | 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]
... | [
"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 |
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 = se... | 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 = se... | [
"def",
"detailxy",
"(",
"self",
",",
"canvas",
",",
"button",
",",
"data_x",
",",
"data_y",
")",
":",
"if",
"button",
"==",
"0",
":",
"chviewer",
"=",
"self",
".",
"fv",
".",
"getfocus_viewer",
"(",
")",
"if",
"chviewer",
"!=",
"self",
".",
"fitsimag... | 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 |
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
usag... | 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
usag... | [
"def",
"reference_viewer",
"(",
"sys_argv",
")",
":",
"viewer",
"=",
"ReferenceViewer",
"(",
"layout",
"=",
"default_layout",
")",
"viewer",
".",
"add_default_plugins",
"(",
")",
"viewer",
".",
"add_separately_distributed_plugins",
"(",
")",
"from",
"optparse",
"i... | 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 |
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 == 'gl... | 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 == 'gl... | [
"def",
"add_default_plugins",
"(",
"self",
",",
"except_global",
"=",
"[",
"]",
",",
"except_local",
"=",
"[",
"]",
")",
":",
"for",
"spec",
"in",
"plugins",
":",
"ptype",
"=",
"spec",
".",
"get",
"(",
"'ptype'",
",",
"'local'",
")",
"if",
"ptype",
"... | 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 |
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="B... | 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="B... | [
"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 |
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)
e... | 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)
e... | [
"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 |
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 |
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... | 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... | [
"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 |
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 = se... | 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 = se... | [
"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 |
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 = sel... | 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 = sel... | [
"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 |
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()
... | 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()
... | [
"def",
"my_import",
"(",
"name",
",",
"path",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"importlib",
",",
"'invalidate_caches'",
")",
":",
"importlib",
".",
"invalidate_caches",
"(",
")",
"if",
"path",
"is",
"not",
"None",
":",
"directory",
",",
"src_... | 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 |
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 |
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... | 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... | [
"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 |
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 <= di... | 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 <= di... | [
"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 |
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 |
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':
... | 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':
... | [
"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 |
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... | 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... | [
"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 |
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':... | 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':... | [
"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 |
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)
... | 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)
... | [
"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 |
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 |
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 |
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 = view... | 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 = view... | [
"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 |
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 == 'do... | 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 == 'do... | [
"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 |
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.... | 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.... | [
"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 |
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=... | 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=... | [
"def",
"sc_cuts_coarse",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"if",
"self",
".",
"cancut",
":",
"self",
".",
"_adjust_cuts",
"(",
"viewer",
",",
"event",
".",
"direction",
",",
"0.1",
",",
"msg",
"=",
"msg",
... | 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 |
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 |
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 |
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)
... | 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)
... | [
"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 |
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 r... | 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 r... | [
"def",
"sc_pan",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"canpan",
":",
"return",
"True",
"rev",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"'pan_reverse'",
",",
"False",
")",
"dire... | 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 |
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 |
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 |
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 |
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
... | 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
... | [
"def",
"pa_naxis",
"(",
"self",
",",
"viewer",
",",
"event",
",",
"msg",
"=",
"True",
")",
":",
"event",
"=",
"self",
".",
"_pa_synth_scroll_event",
"(",
"event",
")",
"if",
"event",
".",
"state",
"!=",
"'move'",
":",
"return",
"False",
"axis",
"=",
... | 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 |
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 (se... | 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 (se... | [
"def",
"mode_key_down",
"(",
"self",
",",
"viewer",
",",
"keyname",
")",
":",
"if",
"keyname",
"not",
"in",
"self",
".",
"mode_map",
":",
"if",
"(",
"keyname",
"not",
"in",
"self",
".",
"mode_tbl",
")",
"or",
"(",
"self",
".",
"_kbdmode",
"!=",
"'met... | 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 |
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
ret... | 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
ret... | [
"def",
"mode_key_up",
"(",
"self",
",",
"viewer",
",",
"keyname",
")",
":",
"if",
"keyname",
"not",
"in",
"self",
".",
"mode_map",
":",
"return",
"False",
"bnch",
"=",
"self",
".",
"mode_map",
"[",
"keyname",
"]",
"if",
"self",
".",
"_kbdmode",
"==",
... | 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 |
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) * mat... | 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) * mat... | [
"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 |
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 |
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 -... | 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 -... | [
"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 |
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 |
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 |
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",
")",
":",
"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 |
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 |
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 |
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 |
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()
... | 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()
... | [
"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 |
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 m... | 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 m... | [
"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 |
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))
band... | 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))
band... | [
"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 |
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 |
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 |
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 s... | 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 s... | [
"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
-------
t... | [
"Trim",
"characters",
"off",
"of",
"the",
"beginnings",
"of",
"text",
"lines",
"."
] | a78c893ec6f37a837de851947e9bb4625c597915 | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/toolbox.py#L107-L130 | train |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.