repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | WCSHelper.get_pixbeam | def get_pixbeam(self, ra, dec):
"""
Determine the beam in pixels at the given location in sky coordinates.
Parameters
----------
ra , dec : float
The sly coordinates at which the beam is determined.
Returns
-------
beam : :class:`AegeanTools.... | python | def get_pixbeam(self, ra, dec):
"""
Determine the beam in pixels at the given location in sky coordinates.
Parameters
----------
ra , dec : float
The sly coordinates at which the beam is determined.
Returns
-------
beam : :class:`AegeanTools.... | [
"def",
"get_pixbeam",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"if",
"ra",
"is",
"None",
":",
"ra",
",",
"dec",
"=",
"self",
".",
"pix2sky",
"(",
"self",
".",
"refpix",
")",
"pos",
"=",
"[",
"ra",
",",
"dec",
"]",
"beam",
"=",
"self",
".... | Determine the beam in pixels at the given location in sky coordinates.
Parameters
----------
ra , dec : float
The sly coordinates at which the beam is determined.
Returns
-------
beam : :class:`AegeanTools.fits_image.Beam`
A beam object, with a/b... | [
"Determine",
"the",
"beam",
"in",
"pixels",
"at",
"the",
"given",
"location",
"in",
"sky",
"coordinates",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L348-L381 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | WCSHelper.get_beamarea_deg2 | def get_beamarea_deg2(self, ra, dec):
"""
Calculate the area of the synthesized beam in square degrees.
Parameters
----------
ra, dec : float
The sky coordinates at which the calculation is made.
Returns
-------
area : float
The b... | python | def get_beamarea_deg2(self, ra, dec):
"""
Calculate the area of the synthesized beam in square degrees.
Parameters
----------
ra, dec : float
The sky coordinates at which the calculation is made.
Returns
-------
area : float
The b... | [
"def",
"get_beamarea_deg2",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"barea",
"=",
"abs",
"(",
"self",
".",
"beam",
".",
"a",
"*",
"self",
".",
"beam",
".",
"b",
"*",
"np",
".",
"pi",
")",
"# in deg**2 at reference coords",
"if",
"self",
".",
... | Calculate the area of the synthesized beam in square degrees.
Parameters
----------
ra, dec : float
The sky coordinates at which the calculation is made.
Returns
-------
area : float
The beam area in square degrees. | [
"Calculate",
"the",
"area",
"of",
"the",
"synthesized",
"beam",
"in",
"square",
"degrees",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L383-L400 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | WCSHelper.get_beamarea_pix | def get_beamarea_pix(self, ra, dec):
"""
Calculate the beam area in square pixels.
Parameters
----------
ra, dec : float
The sky coordinates at which the calculation is made
dec
Returns
-------
area : float
The beam area i... | python | def get_beamarea_pix(self, ra, dec):
"""
Calculate the beam area in square pixels.
Parameters
----------
ra, dec : float
The sky coordinates at which the calculation is made
dec
Returns
-------
area : float
The beam area i... | [
"def",
"get_beamarea_pix",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"parea",
"=",
"abs",
"(",
"self",
".",
"pixscale",
"[",
"0",
"]",
"*",
"self",
".",
"pixscale",
"[",
"1",
"]",
")",
"# in deg**2 at reference coords",
"barea",
"=",
"self",
".",
... | Calculate the beam area in square pixels.
Parameters
----------
ra, dec : float
The sky coordinates at which the calculation is made
dec
Returns
-------
area : float
The beam area in square pixels. | [
"Calculate",
"the",
"beam",
"area",
"in",
"square",
"pixels",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L402-L419 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | WCSHelper.sky_sep | def sky_sep(self, pix1, pix2):
"""
calculate the GCD sky separation (degrees) between two pixels.
Parameters
----------
pix1, pix2 : (float, float)
The (x,y) pixel coordinates for the two positions.
Returns
-------
dist : float
Th... | python | def sky_sep(self, pix1, pix2):
"""
calculate the GCD sky separation (degrees) between two pixels.
Parameters
----------
pix1, pix2 : (float, float)
The (x,y) pixel coordinates for the two positions.
Returns
-------
dist : float
Th... | [
"def",
"sky_sep",
"(",
"self",
",",
"pix1",
",",
"pix2",
")",
":",
"pos1",
"=",
"self",
".",
"pix2sky",
"(",
"pix1",
")",
"pos2",
"=",
"self",
".",
"pix2sky",
"(",
"pix2",
")",
"sep",
"=",
"gcd",
"(",
"pos1",
"[",
"0",
"]",
",",
"pos1",
"[",
... | calculate the GCD sky separation (degrees) between two pixels.
Parameters
----------
pix1, pix2 : (float, float)
The (x,y) pixel coordinates for the two positions.
Returns
-------
dist : float
The distance between the two points (degrees). | [
"calculate",
"the",
"GCD",
"sky",
"separation",
"(",
"degrees",
")",
"between",
"two",
"pixels",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L421-L438 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | PSFHelper.get_psf_sky | def get_psf_sky(self, ra, dec):
"""
Determine the local psf at a given sky location.
The psf is returned in degrees.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
The p... | python | def get_psf_sky(self, ra, dec):
"""
Determine the local psf at a given sky location.
The psf is returned in degrees.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
The p... | [
"def",
"get_psf_sky",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"# If we don't have a psf map then we just fall back to using the beam",
"# from the fits header (including ZA scaling)",
"if",
"self",
".",
"data",
"is",
"None",
":",
"beam",
"=",
"self",
".",
"wcshelp... | Determine the local psf at a given sky location.
The psf is returned in degrees.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
The psf semi-major axis, semi-minor axis, and position an... | [
"Determine",
"the",
"local",
"psf",
"at",
"a",
"given",
"sky",
"location",
".",
"The",
"psf",
"is",
"returned",
"in",
"degrees",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L474-L504 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | PSFHelper.get_psf_pix | def get_psf_pix(self, ra, dec):
"""
Determine the local psf (a,b,pa) at a given sky location.
The psf is in pixel coordinates.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
... | python | def get_psf_pix(self, ra, dec):
"""
Determine the local psf (a,b,pa) at a given sky location.
The psf is in pixel coordinates.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
... | [
"def",
"get_psf_pix",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"psf_sky",
"=",
"self",
".",
"get_psf_sky",
"(",
"ra",
",",
"dec",
")",
"psf_pix",
"=",
"self",
".",
"wcshelper",
".",
"sky2pix_ellipse",
"(",
"[",
"ra",
",",
"dec",
"]",
",",
"psf... | Determine the local psf (a,b,pa) at a given sky location.
The psf is in pixel coordinates.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
The psf semi-major axis (pixels), semi-minor ax... | [
"Determine",
"the",
"local",
"psf",
"(",
"a",
"b",
"pa",
")",
"at",
"a",
"given",
"sky",
"location",
".",
"The",
"psf",
"is",
"in",
"pixel",
"coordinates",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L506-L527 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | PSFHelper.get_pixbeam | def get_pixbeam(self, ra, dec):
"""
Get the psf at the location specified in pixel coordinates.
The psf is also in pixel coordinates.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
... | python | def get_pixbeam(self, ra, dec):
"""
Get the psf at the location specified in pixel coordinates.
The psf is also in pixel coordinates.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
... | [
"def",
"get_pixbeam",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"# If there is no psf image then just use the fits header (plus lat scaling) from the wcshelper",
"if",
"self",
".",
"data",
"is",
"None",
":",
"return",
"self",
".",
"wcshelper",
".",
"get_pixbeam",
... | Get the psf at the location specified in pixel coordinates.
The psf is also in pixel coordinates.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
a, b, pa : float
The psf semi-major axis (pixels), semi-mi... | [
"Get",
"the",
"psf",
"at",
"the",
"location",
"specified",
"in",
"pixel",
"coordinates",
".",
"The",
"psf",
"is",
"also",
"in",
"pixel",
"coordinates",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L552-L578 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | PSFHelper.get_beam | def get_beam(self, ra, dec):
"""
Get the psf as a :class:`AegeanTools.fits_image.Beam` object.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
beam : :class:`AegeanTools.fits_image.Beam`
The psf a... | python | def get_beam(self, ra, dec):
"""
Get the psf as a :class:`AegeanTools.fits_image.Beam` object.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
beam : :class:`AegeanTools.fits_image.Beam`
The psf a... | [
"def",
"get_beam",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"if",
"self",
".",
"data",
"is",
"None",
":",
"return",
"self",
".",
"wcshelper",
".",
"beam",
"else",
":",
"psf",
"=",
"self",
".",
"get_psf_sky",
"(",
"ra",
",",
"dec",
")",
"if",... | Get the psf as a :class:`AegeanTools.fits_image.Beam` object.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
beam : :class:`AegeanTools.fits_image.Beam`
The psf at the given location. | [
"Get",
"the",
"psf",
"as",
"a",
":",
"class",
":",
"AegeanTools",
".",
"fits_image",
".",
"Beam",
"object",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L580-L600 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | PSFHelper.get_beamarea_pix | def get_beamarea_pix(self, ra, dec):
"""
Calculate the area of the beam in square pixels.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
area : float
The area of the beam in square pixels.
... | python | def get_beamarea_pix(self, ra, dec):
"""
Calculate the area of the beam in square pixels.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
area : float
The area of the beam in square pixels.
... | [
"def",
"get_beamarea_pix",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"beam",
"=",
"self",
".",
"get_pixbeam",
"(",
"ra",
",",
"dec",
")",
"if",
"beam",
"is",
"None",
":",
"return",
"0",
"return",
"beam",
".",
"a",
"*",
"beam",
".",
"b",
"*",
... | Calculate the area of the beam in square pixels.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
area : float
The area of the beam in square pixels. | [
"Calculate",
"the",
"area",
"of",
"the",
"beam",
"in",
"square",
"pixels",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L602-L619 | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | PSFHelper.get_beamarea_deg2 | def get_beamarea_deg2(self, ra, dec):
"""
Calculate the area of the beam in square degrees.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
area : float
The area of the beam in square degrees.
... | python | def get_beamarea_deg2(self, ra, dec):
"""
Calculate the area of the beam in square degrees.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
area : float
The area of the beam in square degrees.
... | [
"def",
"get_beamarea_deg2",
"(",
"self",
",",
"ra",
",",
"dec",
")",
":",
"beam",
"=",
"self",
".",
"get_beam",
"(",
"ra",
",",
"dec",
")",
"if",
"beam",
"is",
"None",
":",
"return",
"0",
"return",
"beam",
".",
"a",
"*",
"beam",
".",
"b",
"*",
... | Calculate the area of the beam in square degrees.
Parameters
----------
ra, dec : float
The sky position (degrees).
Returns
-------
area : float
The area of the beam in square degrees. | [
"Calculate",
"the",
"area",
"of",
"the",
"beam",
"in",
"square",
"degrees",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L621-L639 | train |
PaulHancock/Aegean | AegeanTools/msq2.py | MarchingSquares.find_start_point | def find_start_point(self):
"""
Find the first location in our array that is not empty
"""
for i, row in enumerate(self.data):
for j, _ in enumerate(row):
if self.data[i, j] != 0: # or not np.isfinite(self.data[i,j]):
return i, j | python | def find_start_point(self):
"""
Find the first location in our array that is not empty
"""
for i, row in enumerate(self.data):
for j, _ in enumerate(row):
if self.data[i, j] != 0: # or not np.isfinite(self.data[i,j]):
return i, j | [
"def",
"find_start_point",
"(",
"self",
")",
":",
"for",
"i",
",",
"row",
"in",
"enumerate",
"(",
"self",
".",
"data",
")",
":",
"for",
"j",
",",
"_",
"in",
"enumerate",
"(",
"row",
")",
":",
"if",
"self",
".",
"data",
"[",
"i",
",",
"j",
"]",
... | Find the first location in our array that is not empty | [
"Find",
"the",
"first",
"location",
"in",
"our",
"array",
"that",
"is",
"not",
"empty"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L36-L43 | train |
PaulHancock/Aegean | AegeanTools/msq2.py | MarchingSquares.step | def step(self, x, y):
"""
Move from the current location to the next
Parameters
----------
x, y : int
The current location
"""
up_left = self.solid(x - 1, y - 1)
up_right = self.solid(x, y - 1)
down_left = self.solid(x - 1, y)
... | python | def step(self, x, y):
"""
Move from the current location to the next
Parameters
----------
x, y : int
The current location
"""
up_left = self.solid(x - 1, y - 1)
up_right = self.solid(x, y - 1)
down_left = self.solid(x - 1, y)
... | [
"def",
"step",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"up_left",
"=",
"self",
".",
"solid",
"(",
"x",
"-",
"1",
",",
"y",
"-",
"1",
")",
"up_right",
"=",
"self",
".",
"solid",
"(",
"x",
",",
"y",
"-",
"1",
")",
"down_left",
"=",
"self",... | Move from the current location to the next
Parameters
----------
x, y : int
The current location | [
"Move",
"from",
"the",
"current",
"location",
"to",
"the",
"next"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L45-L92 | train |
PaulHancock/Aegean | AegeanTools/msq2.py | MarchingSquares.solid | def solid(self, x, y):
"""
Determine whether the pixel x,y is nonzero
Parameters
----------
x, y : int
The pixel of interest.
Returns
-------
solid : bool
True if the pixel is not zero.
"""
if not(0 <= x < self.xsi... | python | def solid(self, x, y):
"""
Determine whether the pixel x,y is nonzero
Parameters
----------
x, y : int
The pixel of interest.
Returns
-------
solid : bool
True if the pixel is not zero.
"""
if not(0 <= x < self.xsi... | [
"def",
"solid",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"not",
"(",
"0",
"<=",
"x",
"<",
"self",
".",
"xsize",
")",
"or",
"not",
"(",
"0",
"<=",
"y",
"<",
"self",
".",
"ysize",
")",
":",
"return",
"False",
"if",
"self",
".",
"data"... | Determine whether the pixel x,y is nonzero
Parameters
----------
x, y : int
The pixel of interest.
Returns
-------
solid : bool
True if the pixel is not zero. | [
"Determine",
"whether",
"the",
"pixel",
"x",
"y",
"is",
"nonzero"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L94-L112 | train |
PaulHancock/Aegean | AegeanTools/msq2.py | MarchingSquares.walk_perimeter | def walk_perimeter(self, startx, starty):
"""
Starting at a point on the perimeter of a region, 'walk' the perimeter to return
to the starting point. Record the path taken.
Parameters
----------
startx, starty : int
The starting location. Assumed to be on the... | python | def walk_perimeter(self, startx, starty):
"""
Starting at a point on the perimeter of a region, 'walk' the perimeter to return
to the starting point. Record the path taken.
Parameters
----------
startx, starty : int
The starting location. Assumed to be on the... | [
"def",
"walk_perimeter",
"(",
"self",
",",
"startx",
",",
"starty",
")",
":",
"# checks",
"startx",
"=",
"max",
"(",
"startx",
",",
"0",
")",
"startx",
"=",
"min",
"(",
"startx",
",",
"self",
".",
"xsize",
")",
"starty",
"=",
"max",
"(",
"starty",
... | Starting at a point on the perimeter of a region, 'walk' the perimeter to return
to the starting point. Record the path taken.
Parameters
----------
startx, starty : int
The starting location. Assumed to be on the perimeter of a region.
Returns
-------
... | [
"Starting",
"at",
"a",
"point",
"on",
"the",
"perimeter",
"of",
"a",
"region",
"walk",
"the",
"perimeter",
"to",
"return",
"to",
"the",
"starting",
"point",
".",
"Record",
"the",
"path",
"taken",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L114-L157 | train |
PaulHancock/Aegean | AegeanTools/msq2.py | MarchingSquares.do_march | def do_march(self):
"""
March about and trace the outline of our object
Returns
-------
perimeter : list
The pixels on the perimeter of the region [[x1, y1], ...]
"""
x, y = self.find_start_point()
perimeter = self.walk_perimeter(x, y)
... | python | def do_march(self):
"""
March about and trace the outline of our object
Returns
-------
perimeter : list
The pixels on the perimeter of the region [[x1, y1], ...]
"""
x, y = self.find_start_point()
perimeter = self.walk_perimeter(x, y)
... | [
"def",
"do_march",
"(",
"self",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"find_start_point",
"(",
")",
"perimeter",
"=",
"self",
".",
"walk_perimeter",
"(",
"x",
",",
"y",
")",
"return",
"perimeter"
] | March about and trace the outline of our object
Returns
-------
perimeter : list
The pixels on the perimeter of the region [[x1, y1], ...] | [
"March",
"about",
"and",
"trace",
"the",
"outline",
"of",
"our",
"object"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L159-L170 | train |
PaulHancock/Aegean | AegeanTools/msq2.py | MarchingSquares._blank_within | def _blank_within(self, perimeter):
"""
Blank all the pixels within the given perimeter.
Parameters
----------
perimeter : list
The perimeter of the region.
"""
# Method:
# scan around the perimeter filling 'up' from each pixel
# stop... | python | def _blank_within(self, perimeter):
"""
Blank all the pixels within the given perimeter.
Parameters
----------
perimeter : list
The perimeter of the region.
"""
# Method:
# scan around the perimeter filling 'up' from each pixel
# stop... | [
"def",
"_blank_within",
"(",
"self",
",",
"perimeter",
")",
":",
"# Method:",
"# scan around the perimeter filling 'up' from each pixel",
"# stopping when we reach the other boundary",
"for",
"p",
"in",
"perimeter",
":",
"# if we are on the edge of the data then there is nothing to f... | Blank all the pixels within the given perimeter.
Parameters
----------
perimeter : list
The perimeter of the region. | [
"Blank",
"all",
"the",
"pixels",
"within",
"the",
"given",
"perimeter",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L172-L205 | train |
PaulHancock/Aegean | AegeanTools/msq2.py | MarchingSquares.do_march_all | def do_march_all(self):
"""
Recursive march in the case that we have a fragmented shape.
Returns
-------
perimeters : [perimeter1, ...]
The perimeters of all the regions in the image.
See Also
--------
:func:`AegeanTools.msq2.MarchingSquares.d... | python | def do_march_all(self):
"""
Recursive march in the case that we have a fragmented shape.
Returns
-------
perimeters : [perimeter1, ...]
The perimeters of all the regions in the image.
See Also
--------
:func:`AegeanTools.msq2.MarchingSquares.d... | [
"def",
"do_march_all",
"(",
"self",
")",
":",
"# copy the data since we are going to be modifying it",
"data_copy",
"=",
"copy",
"(",
"self",
".",
"data",
")",
"# iterate through finding an island, creating a perimeter,",
"# and then blanking the island",
"perimeters",
"=",
"["... | Recursive march in the case that we have a fragmented shape.
Returns
-------
perimeters : [perimeter1, ...]
The perimeters of all the regions in the image.
See Also
--------
:func:`AegeanTools.msq2.MarchingSquares.do_march` | [
"Recursive",
"march",
"in",
"the",
"case",
"that",
"we",
"have",
"a",
"fragmented",
"shape",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L207-L236 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | elliptical_gaussian | def elliptical_gaussian(x, y, amp, xo, yo, sx, sy, theta):
"""
Generate a model 2d Gaussian with the given parameters.
Evaluate this model at the given locations x,y.
Parameters
----------
x, y : numeric or array-like
locations at which to evaluate the gaussian
amp : float
P... | python | def elliptical_gaussian(x, y, amp, xo, yo, sx, sy, theta):
"""
Generate a model 2d Gaussian with the given parameters.
Evaluate this model at the given locations x,y.
Parameters
----------
x, y : numeric or array-like
locations at which to evaluate the gaussian
amp : float
P... | [
"def",
"elliptical_gaussian",
"(",
"x",
",",
"y",
",",
"amp",
",",
"xo",
",",
"yo",
",",
"sx",
",",
"sy",
",",
"theta",
")",
":",
"try",
":",
"sint",
",",
"cost",
"=",
"math",
".",
"sin",
"(",
"np",
".",
"radians",
"(",
"theta",
")",
")",
","... | Generate a model 2d Gaussian with the given parameters.
Evaluate this model at the given locations x,y.
Parameters
----------
x, y : numeric or array-like
locations at which to evaluate the gaussian
amp : float
Peak value.
xo, yo : float
Center of the gaussian.
sx, s... | [
"Generate",
"a",
"model",
"2d",
"Gaussian",
"with",
"the",
"given",
"parameters",
".",
"Evaluate",
"this",
"model",
"at",
"the",
"given",
"locations",
"x",
"y",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L30-L63 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | Cmatrix | def Cmatrix(x, y, sx, sy, theta):
"""
Construct a correlation matrix corresponding to the data.
The matrix assumes a gaussian correlation function.
Parameters
----------
x, y : array-like
locations at which to evaluate the correlation matirx
sx, sy : float
major/minor axes o... | python | def Cmatrix(x, y, sx, sy, theta):
"""
Construct a correlation matrix corresponding to the data.
The matrix assumes a gaussian correlation function.
Parameters
----------
x, y : array-like
locations at which to evaluate the correlation matirx
sx, sy : float
major/minor axes o... | [
"def",
"Cmatrix",
"(",
"x",
",",
"y",
",",
"sx",
",",
"sy",
",",
"theta",
")",
":",
"C",
"=",
"np",
".",
"vstack",
"(",
"[",
"elliptical_gaussian",
"(",
"x",
",",
"y",
",",
"1",
",",
"i",
",",
"j",
",",
"sx",
",",
"sy",
",",
"theta",
")",
... | Construct a correlation matrix corresponding to the data.
The matrix assumes a gaussian correlation function.
Parameters
----------
x, y : array-like
locations at which to evaluate the correlation matirx
sx, sy : float
major/minor axes of the gaussian correlation function (sigmas)
... | [
"Construct",
"a",
"correlation",
"matrix",
"corresponding",
"to",
"the",
"data",
".",
"The",
"matrix",
"assumes",
"a",
"gaussian",
"correlation",
"function",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L66-L87 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | Bmatrix | def Bmatrix(C):
"""
Calculate a matrix which is effectively the square root of the correlation matrix C
Parameters
----------
C : 2d array
A covariance matrix
Returns
-------
B : 2d array
A matrix B such the B.dot(B') = inv(C)
"""
# this version of finding the ... | python | def Bmatrix(C):
"""
Calculate a matrix which is effectively the square root of the correlation matrix C
Parameters
----------
C : 2d array
A covariance matrix
Returns
-------
B : 2d array
A matrix B such the B.dot(B') = inv(C)
"""
# this version of finding the ... | [
"def",
"Bmatrix",
"(",
"C",
")",
":",
"# this version of finding the square root of the inverse matrix",
"# suggested by Cath Trott",
"L",
",",
"Q",
"=",
"eigh",
"(",
"C",
")",
"# force very small eigenvalues to have some minimum non-zero value",
"minL",
"=",
"1e-9",
"*",
"... | Calculate a matrix which is effectively the square root of the correlation matrix C
Parameters
----------
C : 2d array
A covariance matrix
Returns
-------
B : 2d array
A matrix B such the B.dot(B') = inv(C) | [
"Calculate",
"a",
"matrix",
"which",
"is",
"effectively",
"the",
"square",
"root",
"of",
"the",
"correlation",
"matrix",
"C"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L90-L113 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | jacobian | def jacobian(pars, x, y):
"""
Analytical calculation of the Jacobian for an elliptical gaussian
Will work for a model that contains multiple Gaussians, and for which
some components are not being fit (don't vary).
Parameters
----------
pars : lmfit.Model
The model parameters
x, ... | python | def jacobian(pars, x, y):
"""
Analytical calculation of the Jacobian for an elliptical gaussian
Will work for a model that contains multiple Gaussians, and for which
some components are not being fit (don't vary).
Parameters
----------
pars : lmfit.Model
The model parameters
x, ... | [
"def",
"jacobian",
"(",
"pars",
",",
"x",
",",
"y",
")",
":",
"matrix",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"pars",
"[",
"'components'",
"]",
".",
"value",
")",
":",
"prefix",
"=",
"\"c{0}_\"",
".",
"format",
"(",
"i",
")",
"amp",
"=... | Analytical calculation of the Jacobian for an elliptical gaussian
Will work for a model that contains multiple Gaussians, and for which
some components are not being fit (don't vary).
Parameters
----------
pars : lmfit.Model
The model parameters
x, y : list
Locations at which th... | [
"Analytical",
"calculation",
"of",
"the",
"Jacobian",
"for",
"an",
"elliptical",
"gaussian",
"Will",
"work",
"for",
"a",
"model",
"that",
"contains",
"multiple",
"Gaussians",
"and",
"for",
"which",
"some",
"components",
"are",
"not",
"being",
"fit",
"(",
"don"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L116-L188 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | lmfit_jacobian | def lmfit_jacobian(pars, x, y, errs=None, B=None, emp=False):
"""
Wrapper around :func:`AegeanTools.fitting.jacobian` and :func:`AegeanTools.fitting.emp_jacobian`
which gives the output in a format that is required for lmfit.
Parameters
----------
pars : lmfit.Model
The model parameters... | python | def lmfit_jacobian(pars, x, y, errs=None, B=None, emp=False):
"""
Wrapper around :func:`AegeanTools.fitting.jacobian` and :func:`AegeanTools.fitting.emp_jacobian`
which gives the output in a format that is required for lmfit.
Parameters
----------
pars : lmfit.Model
The model parameters... | [
"def",
"lmfit_jacobian",
"(",
"pars",
",",
"x",
",",
"y",
",",
"errs",
"=",
"None",
",",
"B",
"=",
"None",
",",
"emp",
"=",
"False",
")",
":",
"if",
"emp",
":",
"matrix",
"=",
"emp_jacobian",
"(",
"pars",
",",
"x",
",",
"y",
")",
"else",
":",
... | Wrapper around :func:`AegeanTools.fitting.jacobian` and :func:`AegeanTools.fitting.emp_jacobian`
which gives the output in a format that is required for lmfit.
Parameters
----------
pars : lmfit.Model
The model parameters
x, y : list
Locations at which the jacobian is being evaluat... | [
"Wrapper",
"around",
":",
"func",
":",
"AegeanTools",
".",
"fitting",
".",
"jacobian",
"and",
":",
"func",
":",
"AegeanTools",
".",
"fitting",
".",
"emp_jacobian",
"which",
"gives",
"the",
"output",
"in",
"a",
"format",
"that",
"is",
"required",
"for",
"lm... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L228-L279 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | hessian | def hessian(pars, x, y):
"""
Create a hessian matrix corresponding to the source model 'pars'
Only parameters that vary will contribute to the hessian.
Thus there will be a total of nvar x nvar entries, each of which is a
len(x) x len(y) array.
Parameters
----------
pars : lmfit.Paramet... | python | def hessian(pars, x, y):
"""
Create a hessian matrix corresponding to the source model 'pars'
Only parameters that vary will contribute to the hessian.
Thus there will be a total of nvar x nvar entries, each of which is a
len(x) x len(y) array.
Parameters
----------
pars : lmfit.Paramet... | [
"def",
"hessian",
"(",
"pars",
",",
"x",
",",
"y",
")",
":",
"j",
"=",
"0",
"# keeping track of the number of variable parameters",
"# total number of variable parameters",
"ntvar",
"=",
"np",
".",
"sum",
"(",
"[",
"pars",
"[",
"k",
"]",
".",
"vary",
"for",
... | Create a hessian matrix corresponding to the source model 'pars'
Only parameters that vary will contribute to the hessian.
Thus there will be a total of nvar x nvar entries, each of which is a
len(x) x len(y) array.
Parameters
----------
pars : lmfit.Parameters
The model
x, y : list... | [
"Create",
"a",
"hessian",
"matrix",
"corresponding",
"to",
"the",
"source",
"model",
"pars",
"Only",
"parameters",
"that",
"vary",
"will",
"contribute",
"to",
"the",
"hessian",
".",
"Thus",
"there",
"will",
"be",
"a",
"total",
"of",
"nvar",
"x",
"nvar",
"e... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L282-L572 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | emp_hessian | def emp_hessian(pars, x, y):
"""
Calculate the hessian matrix empirically.
Create a hessian matrix corresponding to the source model 'pars'
Only parameters that vary will contribute to the hessian.
Thus there will be a total of nvar x nvar entries, each of which is a
len(x) x len(y) array.
... | python | def emp_hessian(pars, x, y):
"""
Calculate the hessian matrix empirically.
Create a hessian matrix corresponding to the source model 'pars'
Only parameters that vary will contribute to the hessian.
Thus there will be a total of nvar x nvar entries, each of which is a
len(x) x len(y) array.
... | [
"def",
"emp_hessian",
"(",
"pars",
",",
"x",
",",
"y",
")",
":",
"eps",
"=",
"1e-5",
"matrix",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"pars",
"[",
"'components'",
"]",
".",
"value",
")",
":",
"model",
"=",
"emp_jacobian",
"(",
"pars",
","... | Calculate the hessian matrix empirically.
Create a hessian matrix corresponding to the source model 'pars'
Only parameters that vary will contribute to the hessian.
Thus there will be a total of nvar x nvar entries, each of which is a
len(x) x len(y) array.
Parameters
----------
pars : lmfi... | [
"Calculate",
"the",
"hessian",
"matrix",
"empirically",
".",
"Create",
"a",
"hessian",
"matrix",
"corresponding",
"to",
"the",
"source",
"model",
"pars",
"Only",
"parameters",
"that",
"vary",
"will",
"contribute",
"to",
"the",
"hessian",
".",
"Thus",
"there",
... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L575-L615 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | nan_acf | def nan_acf(noise):
"""
Calculate the autocorrelation function of the noise
where the noise is a 2d array that may contain nans
Parameters
----------
noise : 2d-array
Noise image.
Returns
-------
acf : 2d-array
The ACF.
"""
corr = np.zeros(noise.shape)
... | python | def nan_acf(noise):
"""
Calculate the autocorrelation function of the noise
where the noise is a 2d array that may contain nans
Parameters
----------
noise : 2d-array
Noise image.
Returns
-------
acf : 2d-array
The ACF.
"""
corr = np.zeros(noise.shape)
... | [
"def",
"nan_acf",
"(",
"noise",
")",
":",
"corr",
"=",
"np",
".",
"zeros",
"(",
"noise",
".",
"shape",
")",
"ix",
",",
"jx",
"=",
"noise",
".",
"shape",
"for",
"i",
"in",
"range",
"(",
"ix",
")",
":",
"si_min",
"=",
"slice",
"(",
"i",
",",
"N... | Calculate the autocorrelation function of the noise
where the noise is a 2d array that may contain nans
Parameters
----------
noise : 2d-array
Noise image.
Returns
-------
acf : 2d-array
The ACF. | [
"Calculate",
"the",
"autocorrelation",
"function",
"of",
"the",
"noise",
"where",
"the",
"noise",
"is",
"a",
"2d",
"array",
"that",
"may",
"contain",
"nans"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L618-L647 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | make_ita | def make_ita(noise, acf=None):
"""
Create the matrix ita of the noise where the noise may be a masked array
where ita(x,y) is the correlation between pixel pairs that have the same separation as x and y.
Parameters
----------
noise : 2d-array
The noise image
acf : 2d-array
... | python | def make_ita(noise, acf=None):
"""
Create the matrix ita of the noise where the noise may be a masked array
where ita(x,y) is the correlation between pixel pairs that have the same separation as x and y.
Parameters
----------
noise : 2d-array
The noise image
acf : 2d-array
... | [
"def",
"make_ita",
"(",
"noise",
",",
"acf",
"=",
"None",
")",
":",
"if",
"acf",
"is",
"None",
":",
"acf",
"=",
"nan_acf",
"(",
"noise",
")",
"# s should be the number of non-masked pixels",
"s",
"=",
"np",
".",
"count_nonzero",
"(",
"np",
".",
"isfinite",... | Create the matrix ita of the noise where the noise may be a masked array
where ita(x,y) is the correlation between pixel pairs that have the same separation as x and y.
Parameters
----------
noise : 2d-array
The noise image
acf : 2d-array
The autocorrelation matrix. (None = calcula... | [
"Create",
"the",
"matrix",
"ita",
"of",
"the",
"noise",
"where",
"the",
"noise",
"may",
"be",
"a",
"masked",
"array",
"where",
"ita",
"(",
"x",
"y",
")",
"is",
"the",
"correlation",
"between",
"pixel",
"pairs",
"that",
"have",
"the",
"same",
"separation"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L650-L682 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | RB_bias | def RB_bias(data, pars, ita=None, acf=None):
"""
Calculate the expected bias on each of the parameters in the model pars.
Only parameters that are allowed to vary will have a bias.
Calculation follows the description of Refrieger & Brown 1998 (cite).
Parameters
----------
data : 2d-array
... | python | def RB_bias(data, pars, ita=None, acf=None):
"""
Calculate the expected bias on each of the parameters in the model pars.
Only parameters that are allowed to vary will have a bias.
Calculation follows the description of Refrieger & Brown 1998 (cite).
Parameters
----------
data : 2d-array
... | [
"def",
"RB_bias",
"(",
"data",
",",
"pars",
",",
"ita",
"=",
"None",
",",
"acf",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"\"data {0}\"",
".",
"format",
"(",
"data",
".",
"shape",
")",
")",
"nparams",
"=",
"np",
".",
"sum",
"(",
"[",
"pa... | Calculate the expected bias on each of the parameters in the model pars.
Only parameters that are allowed to vary will have a bias.
Calculation follows the description of Refrieger & Brown 1998 (cite).
Parameters
----------
data : 2d-array
data that was fit
pars : lmfit.Parameters
... | [
"Calculate",
"the",
"expected",
"bias",
"on",
"each",
"of",
"the",
"parameters",
"in",
"the",
"model",
"pars",
".",
"Only",
"parameters",
"that",
"are",
"allowed",
"to",
"vary",
"will",
"have",
"a",
"bias",
".",
"Calculation",
"follows",
"the",
"description"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L685-L757 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | bias_correct | def bias_correct(params, data, acf=None):
"""
Calculate and apply a bias correction to the given fit parameters
Parameters
----------
params : lmfit.Parameters
The model parameters. These will be modified.
data : 2d-array
The data which was used in the fitting
acf : 2d-ar... | python | def bias_correct(params, data, acf=None):
"""
Calculate and apply a bias correction to the given fit parameters
Parameters
----------
params : lmfit.Parameters
The model parameters. These will be modified.
data : 2d-array
The data which was used in the fitting
acf : 2d-ar... | [
"def",
"bias_correct",
"(",
"params",
",",
"data",
",",
"acf",
"=",
"None",
")",
":",
"bias",
"=",
"RB_bias",
"(",
"data",
",",
"params",
",",
"acf",
"=",
"acf",
")",
"i",
"=",
"0",
"for",
"p",
"in",
"params",
":",
"if",
"'theta'",
"in",
"p",
"... | Calculate and apply a bias correction to the given fit parameters
Parameters
----------
params : lmfit.Parameters
The model parameters. These will be modified.
data : 2d-array
The data which was used in the fitting
acf : 2d-array
ACF of the data. Default = None.
Retu... | [
"Calculate",
"and",
"apply",
"a",
"bias",
"correction",
"to",
"the",
"given",
"fit",
"parameters"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L760-L792 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | condon_errors | def condon_errors(source, theta_n, psf=None):
"""
Calculate the parameter errors for a fitted source
using the description of Condon'97
All parameters are assigned errors, assuming that all params were fit.
If some params were held fixed then these errors are overestimated.
Parameters
-----... | python | def condon_errors(source, theta_n, psf=None):
"""
Calculate the parameter errors for a fitted source
using the description of Condon'97
All parameters are assigned errors, assuming that all params were fit.
If some params were held fixed then these errors are overestimated.
Parameters
-----... | [
"def",
"condon_errors",
"(",
"source",
",",
"theta_n",
",",
"psf",
"=",
"None",
")",
":",
"# indices for the calculation or rho",
"alphas",
"=",
"{",
"'amp'",
":",
"(",
"3.",
"/",
"2",
",",
"3.",
"/",
"2",
")",
",",
"'major'",
":",
"(",
"5.",
"/",
"2... | Calculate the parameter errors for a fitted source
using the description of Condon'97
All parameters are assigned errors, assuming that all params were fit.
If some params were held fixed then these errors are overestimated.
Parameters
----------
source : :class:`AegeanTools.models.SimpleSource... | [
"Calculate",
"the",
"parameter",
"errors",
"for",
"a",
"fitted",
"source",
"using",
"the",
"description",
"of",
"Condon",
"97",
"All",
"parameters",
"are",
"assigned",
"errors",
"assuming",
"that",
"all",
"params",
"were",
"fit",
".",
"If",
"some",
"params",
... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L795-L868 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | errors | def errors(source, model, wcshelper):
"""
Convert pixel based errors into sky coord errors
Parameters
----------
source : :class:`AegeanTools.models.SimpleSource`
The source which was fit.
model : lmfit.Parameters
The model which was fit.
wcshelper : :class:`AegeanTools.wc... | python | def errors(source, model, wcshelper):
"""
Convert pixel based errors into sky coord errors
Parameters
----------
source : :class:`AegeanTools.models.SimpleSource`
The source which was fit.
model : lmfit.Parameters
The model which was fit.
wcshelper : :class:`AegeanTools.wc... | [
"def",
"errors",
"(",
"source",
",",
"model",
",",
"wcshelper",
")",
":",
"# if the source wasn't fit then all errors are -1",
"if",
"source",
".",
"flags",
"&",
"(",
"flags",
".",
"NOTFIT",
"|",
"flags",
".",
"FITERR",
")",
":",
"source",
".",
"err_peak_flux"... | Convert pixel based errors into sky coord errors
Parameters
----------
source : :class:`AegeanTools.models.SimpleSource`
The source which was fit.
model : lmfit.Parameters
The model which was fit.
wcshelper : :class:`AegeanTools.wcs_helpers.WCSHelper`
WCS information.
... | [
"Convert",
"pixel",
"based",
"errors",
"into",
"sky",
"coord",
"errors"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L871-L969 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | new_errors | def new_errors(source, model, wcshelper): # pragma: no cover
"""
Convert pixel based errors into sky coord errors
Uses covariance matrix for ra/dec errors
and calculus approach to a/b/pa errors
Parameters
----------
source : :class:`AegeanTools.models.SimpleSource`
The source which... | python | def new_errors(source, model, wcshelper): # pragma: no cover
"""
Convert pixel based errors into sky coord errors
Uses covariance matrix for ra/dec errors
and calculus approach to a/b/pa errors
Parameters
----------
source : :class:`AegeanTools.models.SimpleSource`
The source which... | [
"def",
"new_errors",
"(",
"source",
",",
"model",
",",
"wcshelper",
")",
":",
"# pragma: no cover",
"# if the source wasn't fit then all errors are -1",
"if",
"source",
".",
"flags",
"&",
"(",
"flags",
".",
"NOTFIT",
"|",
"flags",
".",
"FITERR",
")",
":",
"sourc... | Convert pixel based errors into sky coord errors
Uses covariance matrix for ra/dec errors
and calculus approach to a/b/pa errors
Parameters
----------
source : :class:`AegeanTools.models.SimpleSource`
The source which was fit.
model : lmfit.Parameters
The model which was fit.
... | [
"Convert",
"pixel",
"based",
"errors",
"into",
"sky",
"coord",
"errors",
"Uses",
"covariance",
"matrix",
"for",
"ra",
"/",
"dec",
"errors",
"and",
"calculus",
"approach",
"to",
"a",
"/",
"b",
"/",
"pa",
"errors"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L972-L1088 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | ntwodgaussian_lmfit | def ntwodgaussian_lmfit(params):
"""
Convert an lmfit.Parameters object into a function which calculates the model.
Parameters
----------
params : lmfit.Parameters
Model parameters, can have multiple components.
Returns
-------
model : func
A function f(x,y) that will ... | python | def ntwodgaussian_lmfit(params):
"""
Convert an lmfit.Parameters object into a function which calculates the model.
Parameters
----------
params : lmfit.Parameters
Model parameters, can have multiple components.
Returns
-------
model : func
A function f(x,y) that will ... | [
"def",
"ntwodgaussian_lmfit",
"(",
"params",
")",
":",
"def",
"rfunc",
"(",
"x",
",",
"y",
")",
":",
"\"\"\"\n Compute the model given by params, at pixel coordinates x,y\n\n Parameters\n ----------\n x, y : numpy.ndarray\n The x/y pixel coordinates... | Convert an lmfit.Parameters object into a function which calculates the model.
Parameters
----------
params : lmfit.Parameters
Model parameters, can have multiple components.
Returns
-------
model : func
A function f(x,y) that will compute the model. | [
"Convert",
"an",
"lmfit",
".",
"Parameters",
"object",
"into",
"a",
"function",
"which",
"calculates",
"the",
"model",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L1091-L1137 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | do_lmfit | def do_lmfit(data, params, B=None, errs=None, dojac=True):
"""
Fit the model to the data
data may contain 'flagged' or 'masked' data with the value of np.NaN
Parameters
----------
data : 2d-array
Image data
params : lmfit.Parameters
Initial model guess.
B : 2d-array
... | python | def do_lmfit(data, params, B=None, errs=None, dojac=True):
"""
Fit the model to the data
data may contain 'flagged' or 'masked' data with the value of np.NaN
Parameters
----------
data : 2d-array
Image data
params : lmfit.Parameters
Initial model guess.
B : 2d-array
... | [
"def",
"do_lmfit",
"(",
"data",
",",
"params",
",",
"B",
"=",
"None",
",",
"errs",
"=",
"None",
",",
"dojac",
"=",
"True",
")",
":",
"# copy the params so as not to change the initial conditions",
"# in case we want to use them elsewhere",
"params",
"=",
"copy",
"."... | Fit the model to the data
data may contain 'flagged' or 'masked' data with the value of np.NaN
Parameters
----------
data : 2d-array
Image data
params : lmfit.Parameters
Initial model guess.
B : 2d-array
B matrix to be used in residual calculations.
Default = N... | [
"Fit",
"the",
"model",
"to",
"the",
"data",
"data",
"may",
"contain",
"flagged",
"or",
"masked",
"data",
"with",
"the",
"value",
"of",
"np",
".",
"NaN"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L1140-L1210 | train |
PaulHancock/Aegean | AegeanTools/fitting.py | covar_errors | def covar_errors(params, data, errs, B, C=None):
"""
Take a set of parameters that were fit with lmfit, and replace the errors
with the 1\sigma errors calculated using the covariance matrix.
Parameters
----------
params : lmfit.Parameters
Model
data : 2d-array
Image data
... | python | def covar_errors(params, data, errs, B, C=None):
"""
Take a set of parameters that were fit with lmfit, and replace the errors
with the 1\sigma errors calculated using the covariance matrix.
Parameters
----------
params : lmfit.Parameters
Model
data : 2d-array
Image data
... | [
"def",
"covar_errors",
"(",
"params",
",",
"data",
",",
"errs",
",",
"B",
",",
"C",
"=",
"None",
")",
":",
"mask",
"=",
"np",
".",
"where",
"(",
"np",
".",
"isfinite",
"(",
"data",
")",
")",
"# calculate the proper parameter errors and copy them across.",
... | Take a set of parameters that were fit with lmfit, and replace the errors
with the 1\sigma errors calculated using the covariance matrix.
Parameters
----------
params : lmfit.Parameters
Model
data : 2d-array
Image data
errs : 2d-array ?
Image noise.
B : 2d-array
... | [
"Take",
"a",
"set",
"of",
"parameters",
"that",
"were",
"fit",
"with",
"lmfit",
"and",
"replace",
"the",
"errors",
"with",
"the",
"1",
"\\",
"sigma",
"errors",
"calculated",
"using",
"the",
"covariance",
"matrix",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fitting.py#L1213-L1269 | train |
PaulHancock/Aegean | AegeanTools/BANE.py | barrier | def barrier(events, sid, kind='neighbour'):
"""
act as a multiprocessing barrier
"""
events[sid].set()
# only wait for the neighbours
if kind=='neighbour':
if sid > 0:
logging.debug("{0} is waiting for {1}".format(sid, sid - 1))
events[sid - 1].wait()
if s... | python | def barrier(events, sid, kind='neighbour'):
"""
act as a multiprocessing barrier
"""
events[sid].set()
# only wait for the neighbours
if kind=='neighbour':
if sid > 0:
logging.debug("{0} is waiting for {1}".format(sid, sid - 1))
events[sid - 1].wait()
if s... | [
"def",
"barrier",
"(",
"events",
",",
"sid",
",",
"kind",
"=",
"'neighbour'",
")",
":",
"events",
"[",
"sid",
"]",
".",
"set",
"(",
")",
"# only wait for the neighbours",
"if",
"kind",
"==",
"'neighbour'",
":",
"if",
"sid",
">",
"0",
":",
"logging",
".... | act as a multiprocessing barrier | [
"act",
"as",
"a",
"multiprocessing",
"barrier"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L34-L50 | train |
PaulHancock/Aegean | AegeanTools/BANE.py | sigmaclip | def sigmaclip(arr, lo, hi, reps=3):
"""
Perform sigma clipping on an array, ignoring non finite values.
During each iteration return an array whose elements c obey:
mean -std*lo < c < mean + std*hi
where mean/std are the mean std of the input array.
Parameters
----------
arr : iterabl... | python | def sigmaclip(arr, lo, hi, reps=3):
"""
Perform sigma clipping on an array, ignoring non finite values.
During each iteration return an array whose elements c obey:
mean -std*lo < c < mean + std*hi
where mean/std are the mean std of the input array.
Parameters
----------
arr : iterabl... | [
"def",
"sigmaclip",
"(",
"arr",
",",
"lo",
",",
"hi",
",",
"reps",
"=",
"3",
")",
":",
"clipped",
"=",
"np",
".",
"array",
"(",
"arr",
")",
"[",
"np",
".",
"isfinite",
"(",
"arr",
")",
"]",
"if",
"len",
"(",
"clipped",
")",
"<",
"1",
":",
"... | Perform sigma clipping on an array, ignoring non finite values.
During each iteration return an array whose elements c obey:
mean -std*lo < c < mean + std*hi
where mean/std are the mean std of the input array.
Parameters
----------
arr : iterable
An iterable array of numeric types.
... | [
"Perform",
"sigma",
"clipping",
"on",
"an",
"array",
"ignoring",
"non",
"finite",
"values",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L53-L102 | train |
PaulHancock/Aegean | AegeanTools/BANE.py | _sf2 | def _sf2(args):
"""
A shallow wrapper for sigma_filter.
Parameters
----------
args : list
A list of arguments for sigma_filter
Returns
-------
None
"""
# an easier to debug traceback when multiprocessing
# thanks to https://stackoverflow.com/a/16618842/1710603
t... | python | def _sf2(args):
"""
A shallow wrapper for sigma_filter.
Parameters
----------
args : list
A list of arguments for sigma_filter
Returns
-------
None
"""
# an easier to debug traceback when multiprocessing
# thanks to https://stackoverflow.com/a/16618842/1710603
t... | [
"def",
"_sf2",
"(",
"args",
")",
":",
"# an easier to debug traceback when multiprocessing",
"# thanks to https://stackoverflow.com/a/16618842/1710603",
"try",
":",
"return",
"sigma_filter",
"(",
"*",
"args",
")",
"except",
":",
"import",
"traceback",
"raise",
"Exception",
... | A shallow wrapper for sigma_filter.
Parameters
----------
args : list
A list of arguments for sigma_filter
Returns
-------
None | [
"A",
"shallow",
"wrapper",
"for",
"sigma_filter",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L105-L124 | train |
PaulHancock/Aegean | AegeanTools/BANE.py | sigma_filter | def sigma_filter(filename, region, step_size, box_size, shape, domask, sid):
"""
Calculate the background and rms for a sub region of an image. The results are
written to shared memory - irms and ibkg.
Parameters
----------
filename : string
Fits file to open
region : list
... | python | def sigma_filter(filename, region, step_size, box_size, shape, domask, sid):
"""
Calculate the background and rms for a sub region of an image. The results are
written to shared memory - irms and ibkg.
Parameters
----------
filename : string
Fits file to open
region : list
... | [
"def",
"sigma_filter",
"(",
"filename",
",",
"region",
",",
"step_size",
",",
"box_size",
",",
"shape",
",",
"domask",
",",
"sid",
")",
":",
"ymin",
",",
"ymax",
"=",
"region",
"logging",
".",
"debug",
"(",
"'rows {0}-{1} starting at {2}'",
".",
"format",
... | Calculate the background and rms for a sub region of an image. The results are
written to shared memory - irms and ibkg.
Parameters
----------
filename : string
Fits file to open
region : list
Region within the fits file that is to be processed. (row_min, row_max).
step_size :... | [
"Calculate",
"the",
"background",
"and",
"rms",
"for",
"a",
"sub",
"region",
"of",
"an",
"image",
".",
"The",
"results",
"are",
"written",
"to",
"shared",
"memory",
"-",
"irms",
"and",
"ibkg",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L127-L267 | train |
PaulHancock/Aegean | AegeanTools/BANE.py | filter_mc_sharemem | def filter_mc_sharemem(filename, step_size, box_size, cores, shape, nslice=None, domask=True):
"""
Calculate the background and noise images corresponding to the input file.
The calculation is done via a box-car approach and uses multiple cores and shared memory.
Parameters
----------
filename ... | python | def filter_mc_sharemem(filename, step_size, box_size, cores, shape, nslice=None, domask=True):
"""
Calculate the background and noise images corresponding to the input file.
The calculation is done via a box-car approach and uses multiple cores and shared memory.
Parameters
----------
filename ... | [
"def",
"filter_mc_sharemem",
"(",
"filename",
",",
"step_size",
",",
"box_size",
",",
"cores",
",",
"shape",
",",
"nslice",
"=",
"None",
",",
"domask",
"=",
"True",
")",
":",
"if",
"cores",
"is",
"None",
":",
"cores",
"=",
"multiprocessing",
".",
"cpu_co... | Calculate the background and noise images corresponding to the input file.
The calculation is done via a box-car approach and uses multiple cores and shared memory.
Parameters
----------
filename : str
Filename to be filtered.
step_size : (int, int)
Step size for the filter.
b... | [
"Calculate",
"the",
"background",
"and",
"noise",
"images",
"corresponding",
"to",
"the",
"input",
"file",
".",
"The",
"calculation",
"is",
"done",
"via",
"a",
"box",
"-",
"car",
"approach",
"and",
"uses",
"multiple",
"cores",
"and",
"shared",
"memory",
"."
... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L270-L363 | train |
PaulHancock/Aegean | AegeanTools/BANE.py | filter_image | def filter_image(im_name, out_base, step_size=None, box_size=None, twopass=False, cores=None, mask=True, compressed=False, nslice=None):
"""
Create a background and noise image from an input image.
Resulting images are written to `outbase_bkg.fits` and `outbase_rms.fits`
Parameters
----------
i... | python | def filter_image(im_name, out_base, step_size=None, box_size=None, twopass=False, cores=None, mask=True, compressed=False, nslice=None):
"""
Create a background and noise image from an input image.
Resulting images are written to `outbase_bkg.fits` and `outbase_rms.fits`
Parameters
----------
i... | [
"def",
"filter_image",
"(",
"im_name",
",",
"out_base",
",",
"step_size",
"=",
"None",
",",
"box_size",
"=",
"None",
",",
"twopass",
"=",
"False",
",",
"cores",
"=",
"None",
",",
"mask",
"=",
"True",
",",
"compressed",
"=",
"False",
",",
"nslice",
"=",... | Create a background and noise image from an input image.
Resulting images are written to `outbase_bkg.fits` and `outbase_rms.fits`
Parameters
----------
im_name : str or HDUList
Image to filter. Either a string filename or an astropy.io.fits.HDUList.
out_base : str
The output filena... | [
"Create",
"a",
"background",
"and",
"noise",
"image",
"from",
"an",
"input",
"image",
".",
"Resulting",
"images",
"are",
"written",
"to",
"outbase_bkg",
".",
"fits",
"and",
"outbase_rms",
".",
"fits"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L366-L461 | train |
PaulHancock/Aegean | AegeanTools/BANE.py | write_fits | def write_fits(data, header, file_name):
"""
Combine data and a fits header to write a fits file.
Parameters
----------
data : numpy.ndarray
The data to be written.
header : astropy.io.fits.hduheader
The header for the fits file.
file_name : string
The file to writ... | python | def write_fits(data, header, file_name):
"""
Combine data and a fits header to write a fits file.
Parameters
----------
data : numpy.ndarray
The data to be written.
header : astropy.io.fits.hduheader
The header for the fits file.
file_name : string
The file to writ... | [
"def",
"write_fits",
"(",
"data",
",",
"header",
",",
"file_name",
")",
":",
"hdu",
"=",
"fits",
".",
"PrimaryHDU",
"(",
"data",
")",
"hdu",
".",
"header",
"=",
"header",
"hdulist",
"=",
"fits",
".",
"HDUList",
"(",
"[",
"hdu",
"]",
")",
"hdulist",
... | Combine data and a fits header to write a fits file.
Parameters
----------
data : numpy.ndarray
The data to be written.
header : astropy.io.fits.hduheader
The header for the fits file.
file_name : string
The file to write
Returns
-------
None | [
"Combine",
"data",
"and",
"a",
"fits",
"header",
"to",
"write",
"a",
"fits",
"file",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/BANE.py#L467-L491 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | dec2dec | def dec2dec(dec):
"""
Convert sexegessimal RA string into a float in degrees.
Parameters
----------
dec : string
A string separated representing the Dec.
Expected format is `[+- ]hh:mm[:ss.s]`
Colons can be replaced with any whit space character.
Returns
-------
... | python | def dec2dec(dec):
"""
Convert sexegessimal RA string into a float in degrees.
Parameters
----------
dec : string
A string separated representing the Dec.
Expected format is `[+- ]hh:mm[:ss.s]`
Colons can be replaced with any whit space character.
Returns
-------
... | [
"def",
"dec2dec",
"(",
"dec",
")",
":",
"d",
"=",
"dec",
".",
"replace",
"(",
"':'",
",",
"' '",
")",
".",
"split",
"(",
")",
"if",
"len",
"(",
"d",
")",
"==",
"2",
":",
"d",
".",
"append",
"(",
"0.0",
")",
"if",
"d",
"[",
"0",
"]",
".",
... | Convert sexegessimal RA string into a float in degrees.
Parameters
----------
dec : string
A string separated representing the Dec.
Expected format is `[+- ]hh:mm[:ss.s]`
Colons can be replaced with any whit space character.
Returns
-------
dec : float
The Dec i... | [
"Convert",
"sexegessimal",
"RA",
"string",
"into",
"a",
"float",
"in",
"degrees",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L38-L59 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | dec2dms | def dec2dms(x):
"""
Convert decimal degrees into a sexagessimal string in degrees.
Parameters
----------
x : float
Angle in degrees
Returns
-------
dms : string
String of format [+-]DD:MM:SS.SS
or XX:XX:XX.XX if x is not finite.
"""
if not np.isfinite(x)... | python | def dec2dms(x):
"""
Convert decimal degrees into a sexagessimal string in degrees.
Parameters
----------
x : float
Angle in degrees
Returns
-------
dms : string
String of format [+-]DD:MM:SS.SS
or XX:XX:XX.XX if x is not finite.
"""
if not np.isfinite(x)... | [
"def",
"dec2dms",
"(",
"x",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"x",
")",
":",
"return",
"'XX:XX:XX.XX'",
"if",
"x",
"<",
"0",
":",
"sign",
"=",
"'-'",
"else",
":",
"sign",
"=",
"'+'",
"x",
"=",
"abs",
"(",
"x",
")",
"d",
"=",
... | Convert decimal degrees into a sexagessimal string in degrees.
Parameters
----------
x : float
Angle in degrees
Returns
-------
dms : string
String of format [+-]DD:MM:SS.SS
or XX:XX:XX.XX if x is not finite. | [
"Convert",
"decimal",
"degrees",
"into",
"a",
"sexagessimal",
"string",
"in",
"degrees",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L62-L87 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | dec2hms | def dec2hms(x):
"""
Convert decimal degrees into a sexagessimal string in hours.
Parameters
----------
x : float
Angle in degrees
Returns
-------
dms : string
String of format HH:MM:SS.SS
or XX:XX:XX.XX if x is not finite.
"""
if not np.isfinite(x):
... | python | def dec2hms(x):
"""
Convert decimal degrees into a sexagessimal string in hours.
Parameters
----------
x : float
Angle in degrees
Returns
-------
dms : string
String of format HH:MM:SS.SS
or XX:XX:XX.XX if x is not finite.
"""
if not np.isfinite(x):
... | [
"def",
"dec2hms",
"(",
"x",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"x",
")",
":",
"return",
"'XX:XX:XX.XX'",
"# wrap negative RA's",
"if",
"x",
"<",
"0",
":",
"x",
"+=",
"360",
"x",
"/=",
"15.0",
"h",
"=",
"int",
"(",
"x",
")",
"x",
... | Convert decimal degrees into a sexagessimal string in hours.
Parameters
----------
x : float
Angle in degrees
Returns
-------
dms : string
String of format HH:MM:SS.SS
or XX:XX:XX.XX if x is not finite. | [
"Convert",
"decimal",
"degrees",
"into",
"a",
"sexagessimal",
"string",
"in",
"hours",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L90-L115 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | gcd | def gcd(ra1, dec1, ra2, dec2):
"""
Calculate the great circle distance between to points using the haversine formula [1]_.
Parameters
----------
ra1, dec1, ra2, dec2 : float
The coordinates of the two points of interest.
Units are in degrees.
Returns
-------
dist : flo... | python | def gcd(ra1, dec1, ra2, dec2):
"""
Calculate the great circle distance between to points using the haversine formula [1]_.
Parameters
----------
ra1, dec1, ra2, dec2 : float
The coordinates of the two points of interest.
Units are in degrees.
Returns
-------
dist : flo... | [
"def",
"gcd",
"(",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
")",
":",
"# TODO: Vincenty formula see - https://en.wikipedia.org/wiki/Great-circle_distance",
"dlon",
"=",
"ra2",
"-",
"ra1",
"dlat",
"=",
"dec2",
"-",
"dec1",
"a",
"=",
"np",
".",
"sin",
"(",
... | Calculate the great circle distance between to points using the haversine formula [1]_.
Parameters
----------
ra1, dec1, ra2, dec2 : float
The coordinates of the two points of interest.
Units are in degrees.
Returns
-------
dist : float
The distance between the two poi... | [
"Calculate",
"the",
"great",
"circle",
"distance",
"between",
"to",
"points",
"using",
"the",
"haversine",
"formula",
"[",
"1",
"]",
"_",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L121-L149 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | bear | def bear(ra1, dec1, ra2, dec2):
"""
Calculate the bearing of point 2 from point 1 along a great circle.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates (de... | python | def bear(ra1, dec1, ra2, dec2):
"""
Calculate the bearing of point 2 from point 1 along a great circle.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates (de... | [
"def",
"bear",
"(",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
")",
":",
"rdec1",
"=",
"np",
".",
"radians",
"(",
"dec1",
")",
"rdec2",
"=",
"np",
".",
"radians",
"(",
"dec2",
")",
"rdlon",
"=",
"np",
".",
"radians",
"(",
"ra2",
"-",
"ra1",
... | Calculate the bearing of point 2 from point 1 along a great circle.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates (degrees) of the two points.
Returns
-... | [
"Calculate",
"the",
"bearing",
"of",
"point",
"2",
"from",
"point",
"1",
"along",
"a",
"great",
"circle",
".",
"The",
"bearing",
"is",
"East",
"of",
"North",
"and",
"is",
"in",
"[",
"0",
"360",
")",
"whereas",
"position",
"angle",
"is",
"also",
"East",... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L152-L173 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | translate | def translate(ra, dec, r, theta):
"""
Translate a given point a distance r in the (initial) direction theta, along a great circle.
Parameters
----------
ra, dec : float
The initial point of interest (degrees).
r, theta : float
The distance and initial direction to translate (d... | python | def translate(ra, dec, r, theta):
"""
Translate a given point a distance r in the (initial) direction theta, along a great circle.
Parameters
----------
ra, dec : float
The initial point of interest (degrees).
r, theta : float
The distance and initial direction to translate (d... | [
"def",
"translate",
"(",
"ra",
",",
"dec",
",",
"r",
",",
"theta",
")",
":",
"factor",
"=",
"np",
".",
"sin",
"(",
"np",
".",
"radians",
"(",
"dec",
")",
")",
"*",
"np",
".",
"cos",
"(",
"np",
".",
"radians",
"(",
"r",
")",
")",
"factor",
"... | Translate a given point a distance r in the (initial) direction theta, along a great circle.
Parameters
----------
ra, dec : float
The initial point of interest (degrees).
r, theta : float
The distance and initial direction to translate (degrees).
Returns
-------
ra, dec ... | [
"Translate",
"a",
"given",
"point",
"a",
"distance",
"r",
"in",
"the",
"(",
"initial",
")",
"direction",
"theta",
"along",
"a",
"great",
"circle",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L176-L200 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | dist_rhumb | def dist_rhumb(ra1, dec1, ra2, dec2):
"""
Calculate the Rhumb line distance between two points [1]_.
A Rhumb line between two points is one which follows a constant bearing.
Parameters
----------
ra1, dec1, ra2, dec2 : float
The position of the two points (degrees).
Returns
---... | python | def dist_rhumb(ra1, dec1, ra2, dec2):
"""
Calculate the Rhumb line distance between two points [1]_.
A Rhumb line between two points is one which follows a constant bearing.
Parameters
----------
ra1, dec1, ra2, dec2 : float
The position of the two points (degrees).
Returns
---... | [
"def",
"dist_rhumb",
"(",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
")",
":",
"# verified against website to give correct results",
"phi1",
"=",
"np",
".",
"radians",
"(",
"dec1",
")",
"phi2",
"=",
"np",
".",
"radians",
"(",
"dec2",
")",
"dphi",
"=",
... | Calculate the Rhumb line distance between two points [1]_.
A Rhumb line between two points is one which follows a constant bearing.
Parameters
----------
ra1, dec1, ra2, dec2 : float
The position of the two points (degrees).
Returns
-------
dist : float
The distance between... | [
"Calculate",
"the",
"Rhumb",
"line",
"distance",
"between",
"two",
"points",
"[",
"1",
"]",
"_",
".",
"A",
"Rhumb",
"line",
"between",
"two",
"points",
"is",
"one",
"which",
"follows",
"a",
"constant",
"bearing",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L203-L237 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | bear_rhumb | def bear_rhumb(ra1, dec1, ra2, dec2):
"""
Calculate the bearing of point 2 from point 1 along a Rhumb line.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates... | python | def bear_rhumb(ra1, dec1, ra2, dec2):
"""
Calculate the bearing of point 2 from point 1 along a Rhumb line.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates... | [
"def",
"bear_rhumb",
"(",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
")",
":",
"# verified against website to give correct results",
"phi1",
"=",
"np",
".",
"radians",
"(",
"dec1",
")",
"phi2",
"=",
"np",
".",
"radians",
"(",
"dec2",
")",
"lambda1",
"=",... | Calculate the bearing of point 2 from point 1 along a Rhumb line.
The bearing is East of North and is in [0, 360), whereas position angle is also East of North but (-180,180]
Parameters
----------
ra1, dec1, ra2, dec2 : float
The sky coordinates (degrees) of the two points.
Returns
---... | [
"Calculate",
"the",
"bearing",
"of",
"point",
"2",
"from",
"point",
"1",
"along",
"a",
"Rhumb",
"line",
".",
"The",
"bearing",
"is",
"East",
"of",
"North",
"and",
"is",
"in",
"[",
"0",
"360",
")",
"whereas",
"position",
"angle",
"is",
"also",
"East",
... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L240-L265 | train |
PaulHancock/Aegean | AegeanTools/angle_tools.py | translate_rhumb | def translate_rhumb(ra, dec, r, theta):
"""
Translate a given point a distance r in the (initial) direction theta, along a Rhumb line.
Parameters
----------
ra, dec : float
The initial point of interest (degrees).
r, theta : float
The distance and initial direction to translate ... | python | def translate_rhumb(ra, dec, r, theta):
"""
Translate a given point a distance r in the (initial) direction theta, along a Rhumb line.
Parameters
----------
ra, dec : float
The initial point of interest (degrees).
r, theta : float
The distance and initial direction to translate ... | [
"def",
"translate_rhumb",
"(",
"ra",
",",
"dec",
",",
"r",
",",
"theta",
")",
":",
"# verified against website to give correct results",
"# with the help of http://williams.best.vwh.net/avform.htm#Rhumb",
"delta",
"=",
"np",
".",
"radians",
"(",
"r",
")",
"phi1",
"=",
... | Translate a given point a distance r in the (initial) direction theta, along a Rhumb line.
Parameters
----------
ra, dec : float
The initial point of interest (degrees).
r, theta : float
The distance and initial direction to translate (degrees).
Returns
-------
ra, dec : fl... | [
"Translate",
"a",
"given",
"point",
"a",
"distance",
"r",
"in",
"the",
"(",
"initial",
")",
"direction",
"theta",
"along",
"a",
"Rhumb",
"line",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/angle_tools.py#L268-L303 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | galactic2fk5 | def galactic2fk5(l, b):
"""
Convert galactic l/b to fk5 ra/dec
Parameters
----------
l, b : float
Galactic coordinates in radians.
Returns
-------
ra, dec : float
FK5 ecliptic coordinates in radians.
"""
a = SkyCoord(l, b, unit=(u.radian, u.radian), frame='galac... | python | def galactic2fk5(l, b):
"""
Convert galactic l/b to fk5 ra/dec
Parameters
----------
l, b : float
Galactic coordinates in radians.
Returns
-------
ra, dec : float
FK5 ecliptic coordinates in radians.
"""
a = SkyCoord(l, b, unit=(u.radian, u.radian), frame='galac... | [
"def",
"galactic2fk5",
"(",
"l",
",",
"b",
")",
":",
"a",
"=",
"SkyCoord",
"(",
"l",
",",
"b",
",",
"unit",
"=",
"(",
"u",
".",
"radian",
",",
"u",
".",
"radian",
")",
",",
"frame",
"=",
"'galactic'",
")",
"return",
"a",
".",
"fk5",
".",
"ra"... | Convert galactic l/b to fk5 ra/dec
Parameters
----------
l, b : float
Galactic coordinates in radians.
Returns
-------
ra, dec : float
FK5 ecliptic coordinates in radians. | [
"Convert",
"galactic",
"l",
"/",
"b",
"to",
"fk5",
"ra",
"/",
"dec"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L77-L92 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | mask_plane | def mask_plane(data, wcs, region, negate=False):
"""
Mask a 2d image (data) such that pixels within 'region' are set to nan.
Parameters
----------
data : 2d-array
Image array.
wcs : astropy.wcs.WCS
WCS for the image in question.
region : :class:`AegeanTools.regions.Region`... | python | def mask_plane(data, wcs, region, negate=False):
"""
Mask a 2d image (data) such that pixels within 'region' are set to nan.
Parameters
----------
data : 2d-array
Image array.
wcs : astropy.wcs.WCS
WCS for the image in question.
region : :class:`AegeanTools.regions.Region`... | [
"def",
"mask_plane",
"(",
"data",
",",
"wcs",
",",
"region",
",",
"negate",
"=",
"False",
")",
":",
"# create an array but don't set the values (they are random)",
"indexes",
"=",
"np",
".",
"empty",
"(",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
"*",
"data"... | Mask a 2d image (data) such that pixels within 'region' are set to nan.
Parameters
----------
data : 2d-array
Image array.
wcs : astropy.wcs.WCS
WCS for the image in question.
region : :class:`AegeanTools.regions.Region`
A region within which the image pixels will be maske... | [
"Mask",
"a",
"2d",
"image",
"(",
"data",
")",
"such",
"that",
"pixels",
"within",
"region",
"are",
"set",
"to",
"nan",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L95-L139 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | mask_file | def mask_file(regionfile, infile, outfile, negate=False):
"""
Created a masked version of file, using a region.
Parameters
----------
regionfile : str
A file which can be loaded as a :class:`AegeanTools.regions.Region`.
The image will be masked according to this region.
infile... | python | def mask_file(regionfile, infile, outfile, negate=False):
"""
Created a masked version of file, using a region.
Parameters
----------
regionfile : str
A file which can be loaded as a :class:`AegeanTools.regions.Region`.
The image will be masked according to this region.
infile... | [
"def",
"mask_file",
"(",
"regionfile",
",",
"infile",
",",
"outfile",
",",
"negate",
"=",
"False",
")",
":",
"# Check that the input file is accessible and then open it",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"infile",
")",
":",
"raise",
"Assertion... | Created a masked version of file, using a region.
Parameters
----------
regionfile : str
A file which can be loaded as a :class:`AegeanTools.regions.Region`.
The image will be masked according to this region.
infile : str
Input FITS image.
outfile : str
Output FIT... | [
"Created",
"a",
"masked",
"version",
"of",
"file",
"using",
"a",
"region",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L142-L191 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | mask_table | def mask_table(region, table, negate=False, racol='ra', deccol='dec'):
"""
Apply a given mask (region) to the table, removing all the rows with ra/dec inside the region
If negate=False then remove the rows with ra/dec outside the region.
Parameters
----------
region : :class:`AegeanTools.regio... | python | def mask_table(region, table, negate=False, racol='ra', deccol='dec'):
"""
Apply a given mask (region) to the table, removing all the rows with ra/dec inside the region
If negate=False then remove the rows with ra/dec outside the region.
Parameters
----------
region : :class:`AegeanTools.regio... | [
"def",
"mask_table",
"(",
"region",
",",
"table",
",",
"negate",
"=",
"False",
",",
"racol",
"=",
"'ra'",
",",
"deccol",
"=",
"'dec'",
")",
":",
"inside",
"=",
"region",
".",
"sky_within",
"(",
"table",
"[",
"racol",
"]",
",",
"table",
"[",
"deccol",... | Apply a given mask (region) to the table, removing all the rows with ra/dec inside the region
If negate=False then remove the rows with ra/dec outside the region.
Parameters
----------
region : :class:`AegeanTools.regions.Region`
Region to mask.
table : Astropy.table.Table
Table t... | [
"Apply",
"a",
"given",
"mask",
"(",
"region",
")",
"to",
"the",
"table",
"removing",
"all",
"the",
"rows",
"with",
"ra",
"/",
"dec",
"inside",
"the",
"region",
"If",
"negate",
"=",
"False",
"then",
"remove",
"the",
"rows",
"with",
"ra",
"/",
"dec",
"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L194-L226 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | mask_catalog | def mask_catalog(regionfile, infile, outfile, negate=False, racol='ra', deccol='dec'):
"""
Apply a region file as a mask to a catalog, removing all the rows with ra/dec inside the region
If negate=False then remove the rows with ra/dec outside the region.
Parameters
----------
regionfile : str... | python | def mask_catalog(regionfile, infile, outfile, negate=False, racol='ra', deccol='dec'):
"""
Apply a region file as a mask to a catalog, removing all the rows with ra/dec inside the region
If negate=False then remove the rows with ra/dec outside the region.
Parameters
----------
regionfile : str... | [
"def",
"mask_catalog",
"(",
"regionfile",
",",
"infile",
",",
"outfile",
",",
"negate",
"=",
"False",
",",
"racol",
"=",
"'ra'",
",",
"deccol",
"=",
"'dec'",
")",
":",
"logging",
".",
"info",
"(",
"\"Loading region from {0}\"",
".",
"format",
"(",
"regionf... | Apply a region file as a mask to a catalog, removing all the rows with ra/dec inside the region
If negate=False then remove the rows with ra/dec outside the region.
Parameters
----------
regionfile : str
A file which can be loaded as a :class:`AegeanTools.regions.Region`.
The catalogue... | [
"Apply",
"a",
"region",
"file",
"as",
"a",
"mask",
"to",
"a",
"catalog",
"removing",
"all",
"the",
"rows",
"with",
"ra",
"/",
"dec",
"inside",
"the",
"region",
"If",
"negate",
"=",
"False",
"then",
"remove",
"the",
"rows",
"with",
"ra",
"/",
"dec",
"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L229-L267 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | mim2reg | def mim2reg(mimfile, regfile):
"""
Convert a MIMAS region (.mim) file into a DS9 region (.reg) file.
Parameters
----------
mimfile : str
Input file in MIMAS format.
regfile : str
Output file.
"""
region = Region.load(mimfile)
region.write_reg(regfile)
logging.i... | python | def mim2reg(mimfile, regfile):
"""
Convert a MIMAS region (.mim) file into a DS9 region (.reg) file.
Parameters
----------
mimfile : str
Input file in MIMAS format.
regfile : str
Output file.
"""
region = Region.load(mimfile)
region.write_reg(regfile)
logging.i... | [
"def",
"mim2reg",
"(",
"mimfile",
",",
"regfile",
")",
":",
"region",
"=",
"Region",
".",
"load",
"(",
"mimfile",
")",
"region",
".",
"write_reg",
"(",
"regfile",
")",
"logging",
".",
"info",
"(",
"\"Converted {0} -> {1}\"",
".",
"format",
"(",
"mimfile",
... | Convert a MIMAS region (.mim) file into a DS9 region (.reg) file.
Parameters
----------
mimfile : str
Input file in MIMAS format.
regfile : str
Output file. | [
"Convert",
"a",
"MIMAS",
"region",
"(",
".",
"mim",
")",
"file",
"into",
"a",
"DS9",
"region",
"(",
".",
"reg",
")",
"file",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L270-L286 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | mim2fits | def mim2fits(mimfile, fitsfile):
"""
Convert a MIMAS region (.mim) file into a MOC region (.fits) file.
Parameters
----------
mimfile : str
Input file in MIMAS format.
fitsfile : str
Output file.
"""
region = Region.load(mimfile)
region.write_fits(fitsfile, moctool=... | python | def mim2fits(mimfile, fitsfile):
"""
Convert a MIMAS region (.mim) file into a MOC region (.fits) file.
Parameters
----------
mimfile : str
Input file in MIMAS format.
fitsfile : str
Output file.
"""
region = Region.load(mimfile)
region.write_fits(fitsfile, moctool=... | [
"def",
"mim2fits",
"(",
"mimfile",
",",
"fitsfile",
")",
":",
"region",
"=",
"Region",
".",
"load",
"(",
"mimfile",
")",
"region",
".",
"write_fits",
"(",
"fitsfile",
",",
"moctool",
"=",
"'MIMAS {0}-{1}'",
".",
"format",
"(",
"__version__",
",",
"__date__... | Convert a MIMAS region (.mim) file into a MOC region (.fits) file.
Parameters
----------
mimfile : str
Input file in MIMAS format.
fitsfile : str
Output file. | [
"Convert",
"a",
"MIMAS",
"region",
"(",
".",
"mim",
")",
"file",
"into",
"a",
"MOC",
"region",
"(",
".",
"fits",
")",
"file",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L289-L304 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | box2poly | def box2poly(line):
"""
Convert a string that describes a box in ds9 format, into a polygon that is given by the corners of the box
Parameters
----------
line : str
A string containing a DS9 region command for a box.
Returns
-------
poly : [ra, dec, ...]
The corners of ... | python | def box2poly(line):
"""
Convert a string that describes a box in ds9 format, into a polygon that is given by the corners of the box
Parameters
----------
line : str
A string containing a DS9 region command for a box.
Returns
-------
poly : [ra, dec, ...]
The corners of ... | [
"def",
"box2poly",
"(",
"line",
")",
":",
"words",
"=",
"re",
".",
"split",
"(",
"'[(\\s,)]'",
",",
"line",
")",
"ra",
"=",
"words",
"[",
"1",
"]",
"dec",
"=",
"words",
"[",
"2",
"]",
"width",
"=",
"words",
"[",
"3",
"]",
"height",
"=",
"words"... | Convert a string that describes a box in ds9 format, into a polygon that is given by the corners of the box
Parameters
----------
line : str
A string containing a DS9 region command for a box.
Returns
-------
poly : [ra, dec, ...]
The corners of the box in clockwise order from ... | [
"Convert",
"a",
"string",
"that",
"describes",
"a",
"box",
"in",
"ds9",
"format",
"into",
"a",
"polygon",
"that",
"is",
"given",
"by",
"the",
"corners",
"of",
"the",
"box"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L307-L338 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | circle2circle | def circle2circle(line):
"""
Parse a string that describes a circle in ds9 format.
Parameters
----------
line : str
A string containing a DS9 region command for a circle.
Returns
-------
circle : [ra, dec, radius]
The center and radius of the circle.
"""
words =... | python | def circle2circle(line):
"""
Parse a string that describes a circle in ds9 format.
Parameters
----------
line : str
A string containing a DS9 region command for a circle.
Returns
-------
circle : [ra, dec, radius]
The center and radius of the circle.
"""
words =... | [
"def",
"circle2circle",
"(",
"line",
")",
":",
"words",
"=",
"re",
".",
"split",
"(",
"'[(,\\s)]'",
",",
"line",
")",
"ra",
"=",
"words",
"[",
"1",
"]",
"dec",
"=",
"words",
"[",
"2",
"]",
"radius",
"=",
"words",
"[",
"3",
"]",
"[",
":",
"-",
... | Parse a string that describes a circle in ds9 format.
Parameters
----------
line : str
A string containing a DS9 region command for a circle.
Returns
-------
circle : [ra, dec, radius]
The center and radius of the circle. | [
"Parse",
"a",
"string",
"that",
"describes",
"a",
"circle",
"in",
"ds9",
"format",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L341-L365 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | poly2poly | def poly2poly(line):
"""
Parse a string of text containing a DS9 description of a polygon.
This function works but is not very robust due to the constraints of healpy.
Parameters
----------
line : str
A string containing a DS9 region command for a polygon.
Returns
-------
... | python | def poly2poly(line):
"""
Parse a string of text containing a DS9 description of a polygon.
This function works but is not very robust due to the constraints of healpy.
Parameters
----------
line : str
A string containing a DS9 region command for a polygon.
Returns
-------
... | [
"def",
"poly2poly",
"(",
"line",
")",
":",
"words",
"=",
"re",
".",
"split",
"(",
"'[(\\s,)]'",
",",
"line",
")",
"ras",
"=",
"np",
".",
"array",
"(",
"words",
"[",
"1",
":",
":",
"2",
"]",
")",
"decs",
"=",
"np",
".",
"array",
"(",
"words",
... | Parse a string of text containing a DS9 description of a polygon.
This function works but is not very robust due to the constraints of healpy.
Parameters
----------
line : str
A string containing a DS9 region command for a polygon.
Returns
-------
poly : [ra, dec, ...]
The... | [
"Parse",
"a",
"string",
"of",
"text",
"containing",
"a",
"DS9",
"description",
"of",
"a",
"polygon",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L368-L397 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | reg2mim | def reg2mim(regfile, mimfile, maxdepth):
"""
Parse a DS9 region file and write a MIMAS region (.mim) file.
Parameters
----------
regfile : str
DS9 region (.reg) file.
mimfile : str
MIMAS region (.mim) file.
maxdepth : str
Depth/resolution of the region file.
"... | python | def reg2mim(regfile, mimfile, maxdepth):
"""
Parse a DS9 region file and write a MIMAS region (.mim) file.
Parameters
----------
regfile : str
DS9 region (.reg) file.
mimfile : str
MIMAS region (.mim) file.
maxdepth : str
Depth/resolution of the region file.
"... | [
"def",
"reg2mim",
"(",
"regfile",
",",
"mimfile",
",",
"maxdepth",
")",
":",
"logging",
".",
"info",
"(",
"\"Reading regions from {0}\"",
".",
"format",
"(",
"regfile",
")",
")",
"lines",
"=",
"(",
"l",
"for",
"l",
"in",
"open",
"(",
"regfile",
",",
"'... | Parse a DS9 region file and write a MIMAS region (.mim) file.
Parameters
----------
regfile : str
DS9 region (.reg) file.
mimfile : str
MIMAS region (.mim) file.
maxdepth : str
Depth/resolution of the region file. | [
"Parse",
"a",
"DS9",
"region",
"file",
"and",
"write",
"a",
"MIMAS",
"region",
"(",
".",
"mim",
")",
"file",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L400-L436 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | combine_regions | def combine_regions(container):
"""
Return a region that is the combination of those specified in the container.
The container is typically a results instance that comes from argparse.
Order of construction is: add regions, subtract regions, add circles, subtract circles,
add polygons, subtract pol... | python | def combine_regions(container):
"""
Return a region that is the combination of those specified in the container.
The container is typically a results instance that comes from argparse.
Order of construction is: add regions, subtract regions, add circles, subtract circles,
add polygons, subtract pol... | [
"def",
"combine_regions",
"(",
"container",
")",
":",
"# create empty region",
"region",
"=",
"Region",
"(",
"container",
".",
"maxdepth",
")",
"# add/rem all the regions from files",
"for",
"r",
"in",
"container",
".",
"add_region",
":",
"logging",
".",
"info",
"... | Return a region that is the combination of those specified in the container.
The container is typically a results instance that comes from argparse.
Order of construction is: add regions, subtract regions, add circles, subtract circles,
add polygons, subtract polygons.
Parameters
----------
co... | [
"Return",
"a",
"region",
"that",
"is",
"the",
"combination",
"of",
"those",
"specified",
"in",
"the",
"container",
".",
"The",
"container",
"is",
"typically",
"a",
"results",
"instance",
"that",
"comes",
"from",
"argparse",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L439-L511 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | intersect_regions | def intersect_regions(flist):
"""
Construct a region which is the intersection of all regions described in the given
list of file names.
Parameters
----------
flist : list
A list of region filenames.
Returns
-------
region : :class:`AegeanTools.regions.Region`
The i... | python | def intersect_regions(flist):
"""
Construct a region which is the intersection of all regions described in the given
list of file names.
Parameters
----------
flist : list
A list of region filenames.
Returns
-------
region : :class:`AegeanTools.regions.Region`
The i... | [
"def",
"intersect_regions",
"(",
"flist",
")",
":",
"if",
"len",
"(",
"flist",
")",
"<",
"2",
":",
"raise",
"Exception",
"(",
"\"Require at least two regions to perform intersection\"",
")",
"a",
"=",
"Region",
".",
"load",
"(",
"flist",
"[",
"0",
"]",
")",
... | Construct a region which is the intersection of all regions described in the given
list of file names.
Parameters
----------
flist : list
A list of region filenames.
Returns
-------
region : :class:`AegeanTools.regions.Region`
The intersection of all regions, possibly empty... | [
"Construct",
"a",
"region",
"which",
"is",
"the",
"intersection",
"of",
"all",
"regions",
"described",
"in",
"the",
"given",
"list",
"of",
"file",
"names",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L514-L534 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | save_region | def save_region(region, filename):
"""
Save the given region to a file
Parameters
----------
region : :class:`AegeanTools.regions.Region`
A region.
filename : str
Output file name.
"""
region.save(filename)
logging.info("Wrote {0}".format(filename))
return | python | def save_region(region, filename):
"""
Save the given region to a file
Parameters
----------
region : :class:`AegeanTools.regions.Region`
A region.
filename : str
Output file name.
"""
region.save(filename)
logging.info("Wrote {0}".format(filename))
return | [
"def",
"save_region",
"(",
"region",
",",
"filename",
")",
":",
"region",
".",
"save",
"(",
"filename",
")",
"logging",
".",
"info",
"(",
"\"Wrote {0}\"",
".",
"format",
"(",
"filename",
")",
")",
"return"
] | Save the given region to a file
Parameters
----------
region : :class:`AegeanTools.regions.Region`
A region.
filename : str
Output file name. | [
"Save",
"the",
"given",
"region",
"to",
"a",
"file"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L537-L551 | train |
PaulHancock/Aegean | AegeanTools/MIMAS.py | save_as_image | def save_as_image(region, filename):
"""
Convert a MIMAS region (.mim) file into a image (eg .png)
Parameters
----------
region : :class:`AegeanTools.regions.Region`
Region of interest.
filename : str
Output filename.
"""
import healpy as hp
pixels = list(region.get... | python | def save_as_image(region, filename):
"""
Convert a MIMAS region (.mim) file into a image (eg .png)
Parameters
----------
region : :class:`AegeanTools.regions.Region`
Region of interest.
filename : str
Output filename.
"""
import healpy as hp
pixels = list(region.get... | [
"def",
"save_as_image",
"(",
"region",
",",
"filename",
")",
":",
"import",
"healpy",
"as",
"hp",
"pixels",
"=",
"list",
"(",
"region",
".",
"get_demoted",
"(",
")",
")",
"order",
"=",
"region",
".",
"maxdepth",
"m",
"=",
"np",
".",
"arange",
"(",
"h... | Convert a MIMAS region (.mim) file into a image (eg .png)
Parameters
----------
region : :class:`AegeanTools.regions.Region`
Region of interest.
filename : str
Output filename. | [
"Convert",
"a",
"MIMAS",
"region",
"(",
".",
"mim",
")",
"file",
"into",
"a",
"image",
"(",
"eg",
".",
"png",
")"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/MIMAS.py#L554-L573 | train |
PaulHancock/Aegean | AegeanTools/fits_image.py | get_pixinfo | def get_pixinfo(header):
"""
Return some pixel information based on the given hdu header
pixarea - the area of a single pixel in deg2
pixscale - the side lengths of a pixel (assuming they are square)
Parameters
----------
header : HDUHeader or dict
FITS header information
Retur... | python | def get_pixinfo(header):
"""
Return some pixel information based on the given hdu header
pixarea - the area of a single pixel in deg2
pixscale - the side lengths of a pixel (assuming they are square)
Parameters
----------
header : HDUHeader or dict
FITS header information
Retur... | [
"def",
"get_pixinfo",
"(",
"header",
")",
":",
"if",
"all",
"(",
"a",
"in",
"header",
"for",
"a",
"in",
"[",
"\"CDELT1\"",
",",
"\"CDELT2\"",
"]",
")",
":",
"pixarea",
"=",
"abs",
"(",
"header",
"[",
"\"CDELT1\"",
"]",
"*",
"header",
"[",
"\"CDELT2\"... | Return some pixel information based on the given hdu header
pixarea - the area of a single pixel in deg2
pixscale - the side lengths of a pixel (assuming they are square)
Parameters
----------
header : HDUHeader or dict
FITS header information
Returns
-------
pixarea : float
... | [
"Return",
"some",
"pixel",
"information",
"based",
"on",
"the",
"given",
"hdu",
"header",
"pixarea",
"-",
"the",
"area",
"of",
"a",
"single",
"pixel",
"in",
"deg2",
"pixscale",
"-",
"the",
"side",
"lengths",
"of",
"a",
"pixel",
"(",
"assuming",
"they",
"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L20-L60 | train |
PaulHancock/Aegean | AegeanTools/fits_image.py | get_beam | def get_beam(header):
"""
Create a :class:`AegeanTools.fits_image.Beam` object from a fits header.
BPA may be missing but will be assumed to be zero.
if BMAJ or BMIN are missing then return None instead of a beam object.
Parameters
----------
header : HDUHeader
The fits header.
... | python | def get_beam(header):
"""
Create a :class:`AegeanTools.fits_image.Beam` object from a fits header.
BPA may be missing but will be assumed to be zero.
if BMAJ or BMIN are missing then return None instead of a beam object.
Parameters
----------
header : HDUHeader
The fits header.
... | [
"def",
"get_beam",
"(",
"header",
")",
":",
"if",
"\"BPA\"",
"not",
"in",
"header",
":",
"log",
".",
"warning",
"(",
"\"BPA not present in fits header, using 0\"",
")",
"bpa",
"=",
"0",
"else",
":",
"bpa",
"=",
"header",
"[",
"\"BPA\"",
"]",
"if",
"\"BMAJ\... | Create a :class:`AegeanTools.fits_image.Beam` object from a fits header.
BPA may be missing but will be assumed to be zero.
if BMAJ or BMIN are missing then return None instead of a beam object.
Parameters
----------
header : HDUHeader
The fits header.
Returns
-------
beam : ... | [
"Create",
"a",
":",
"class",
":",
"AegeanTools",
".",
"fits_image",
".",
"Beam",
"object",
"from",
"a",
"fits",
"header",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L63-L102 | train |
PaulHancock/Aegean | AegeanTools/fits_image.py | fix_aips_header | def fix_aips_header(header):
"""
Search through an image header. If the keywords BMAJ/BMIN/BPA are not set,
but there are AIPS history cards, then we can populate the BMAJ/BMIN/BPA.
Fix the header if possible, otherwise don't. Either way, don't complain.
Parameters
----------
header : HDUH... | python | def fix_aips_header(header):
"""
Search through an image header. If the keywords BMAJ/BMIN/BPA are not set,
but there are AIPS history cards, then we can populate the BMAJ/BMIN/BPA.
Fix the header if possible, otherwise don't. Either way, don't complain.
Parameters
----------
header : HDUH... | [
"def",
"fix_aips_header",
"(",
"header",
")",
":",
"if",
"'BMAJ'",
"in",
"header",
"and",
"'BMIN'",
"in",
"header",
"and",
"'BPA'",
"in",
"header",
":",
"# The header already has the required keys so there is nothing to do",
"return",
"header",
"aips_hist",
"=",
"[",
... | Search through an image header. If the keywords BMAJ/BMIN/BPA are not set,
but there are AIPS history cards, then we can populate the BMAJ/BMIN/BPA.
Fix the header if possible, otherwise don't. Either way, don't complain.
Parameters
----------
header : HDUHeader
Fits header which may or ma... | [
"Search",
"through",
"an",
"image",
"header",
".",
"If",
"the",
"keywords",
"BMAJ",
"/",
"BMIN",
"/",
"BPA",
"are",
"not",
"set",
"but",
"there",
"are",
"AIPS",
"history",
"cards",
"then",
"we",
"can",
"populate",
"the",
"BMAJ",
"/",
"BMIN",
"/",
"BPA"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L105-L145 | train |
PaulHancock/Aegean | AegeanTools/fits_image.py | FitsImage.set_pixels | def set_pixels(self, pixels):
"""
Set the image data.
Will not work if the new image has a different shape than the current image.
Parameters
----------
pixels : numpy.ndarray
New image data
Returns
-------
None
"""
if... | python | def set_pixels(self, pixels):
"""
Set the image data.
Will not work if the new image has a different shape than the current image.
Parameters
----------
pixels : numpy.ndarray
New image data
Returns
-------
None
"""
if... | [
"def",
"set_pixels",
"(",
"self",
",",
"pixels",
")",
":",
"if",
"not",
"(",
"pixels",
".",
"shape",
"==",
"self",
".",
"_pixels",
".",
"shape",
")",
":",
"raise",
"AssertionError",
"(",
"\"Shape mismatch between pixels supplied {0} and existing image pixels {1}\"",... | Set the image data.
Will not work if the new image has a different shape than the current image.
Parameters
----------
pixels : numpy.ndarray
New image data
Returns
-------
None | [
"Set",
"the",
"image",
"data",
".",
"Will",
"not",
"work",
"if",
"the",
"new",
"image",
"has",
"a",
"different",
"shape",
"than",
"the",
"current",
"image",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L235-L254 | train |
PaulHancock/Aegean | AegeanTools/fits_image.py | FitsImage.get_background_rms | def get_background_rms(self):
"""
Calculate the rms of the image. The rms is calculated from the interqurtile range (IQR), to
reduce bias from source pixels.
Returns
-------
rms : float
The image rms.
Notes
-----
The rms value is cach... | python | def get_background_rms(self):
"""
Calculate the rms of the image. The rms is calculated from the interqurtile range (IQR), to
reduce bias from source pixels.
Returns
-------
rms : float
The image rms.
Notes
-----
The rms value is cach... | [
"def",
"get_background_rms",
"(",
"self",
")",
":",
"# TODO: return a proper background RMS ignoring the sources",
"# This is an approximate method suggested by PaulH.",
"# I have no idea where this magic 1.34896 number comes from...",
"if",
"self",
".",
"_rms",
"is",
"None",
":",
"#... | Calculate the rms of the image. The rms is calculated from the interqurtile range (IQR), to
reduce bias from source pixels.
Returns
-------
rms : float
The image rms.
Notes
-----
The rms value is cached after first calculation. | [
"Calculate",
"the",
"rms",
"of",
"the",
"image",
".",
"The",
"rms",
"is",
"calculated",
"from",
"the",
"interqurtile",
"range",
"(",
"IQR",
")",
"to",
"reduce",
"bias",
"from",
"source",
"pixels",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L256-L280 | train |
PaulHancock/Aegean | AegeanTools/fits_image.py | FitsImage.pix2sky | def pix2sky(self, pixel):
"""
Get the sky coordinates for a given image pixel.
Parameters
----------
pixel : (float, float)
Image coordinates.
Returns
-------
ra,dec : float
Sky coordinates (degrees)
"""
pixbox = ... | python | def pix2sky(self, pixel):
"""
Get the sky coordinates for a given image pixel.
Parameters
----------
pixel : (float, float)
Image coordinates.
Returns
-------
ra,dec : float
Sky coordinates (degrees)
"""
pixbox = ... | [
"def",
"pix2sky",
"(",
"self",
",",
"pixel",
")",
":",
"pixbox",
"=",
"numpy",
".",
"array",
"(",
"[",
"pixel",
",",
"pixel",
"]",
")",
"skybox",
"=",
"self",
".",
"wcs",
".",
"all_pix2world",
"(",
"pixbox",
",",
"1",
")",
"return",
"[",
"float",
... | Get the sky coordinates for a given image pixel.
Parameters
----------
pixel : (float, float)
Image coordinates.
Returns
-------
ra,dec : float
Sky coordinates (degrees) | [
"Get",
"the",
"sky",
"coordinates",
"for",
"a",
"given",
"image",
"pixel",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L282-L299 | train |
PaulHancock/Aegean | AegeanTools/fits_image.py | FitsImage.sky2pix | def sky2pix(self, skypos):
"""
Get the pixel coordinates for a given sky position (degrees).
Parameters
----------
skypos : (float,float)
ra,dec position in degrees.
Returns
-------
x,y : float
Pixel coordinates.
"""
... | python | def sky2pix(self, skypos):
"""
Get the pixel coordinates for a given sky position (degrees).
Parameters
----------
skypos : (float,float)
ra,dec position in degrees.
Returns
-------
x,y : float
Pixel coordinates.
"""
... | [
"def",
"sky2pix",
"(",
"self",
",",
"skypos",
")",
":",
"skybox",
"=",
"[",
"skypos",
",",
"skypos",
"]",
"pixbox",
"=",
"self",
".",
"wcs",
".",
"all_world2pix",
"(",
"skybox",
",",
"1",
")",
"return",
"[",
"float",
"(",
"pixbox",
"[",
"0",
"]",
... | Get the pixel coordinates for a given sky position (degrees).
Parameters
----------
skypos : (float,float)
ra,dec position in degrees.
Returns
-------
x,y : float
Pixel coordinates. | [
"Get",
"the",
"pixel",
"coordinates",
"for",
"a",
"given",
"sky",
"position",
"(",
"degrees",
")",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/fits_image.py#L307-L324 | train |
PaulHancock/Aegean | AegeanTools/AeRes.py | load_sources | def load_sources(filename):
"""
Open a file, read contents, return a list of all the sources in that file.
@param filename:
@return: list of OutputSource objects
"""
catalog = catalogs.table_to_source_list(catalogs.load_table(filename))
logging.info("read {0} sources from {1}".format(len(cat... | python | def load_sources(filename):
"""
Open a file, read contents, return a list of all the sources in that file.
@param filename:
@return: list of OutputSource objects
"""
catalog = catalogs.table_to_source_list(catalogs.load_table(filename))
logging.info("read {0} sources from {1}".format(len(cat... | [
"def",
"load_sources",
"(",
"filename",
")",
":",
"catalog",
"=",
"catalogs",
".",
"table_to_source_list",
"(",
"catalogs",
".",
"load_table",
"(",
"filename",
")",
")",
"logging",
".",
"info",
"(",
"\"read {0} sources from {1}\"",
".",
"format",
"(",
"len",
"... | Open a file, read contents, return a list of all the sources in that file.
@param filename:
@return: list of OutputSource objects | [
"Open",
"a",
"file",
"read",
"contents",
"return",
"a",
"list",
"of",
"all",
"the",
"sources",
"in",
"that",
"file",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/AeRes.py#L19-L27 | train |
PaulHancock/Aegean | scripts/fix_beam.py | search_beam | def search_beam(hdulist):
"""
Will search the beam info from the HISTORY
:param hdulist:
:return:
"""
header = hdulist[0].header
history = header['HISTORY']
history_str = str(history)
#AIPS CLEAN BMAJ= 1.2500E-02 BMIN= 1.2500E-02 BPA= 0.00
if 'BMAJ' in history_str:
... | python | def search_beam(hdulist):
"""
Will search the beam info from the HISTORY
:param hdulist:
:return:
"""
header = hdulist[0].header
history = header['HISTORY']
history_str = str(history)
#AIPS CLEAN BMAJ= 1.2500E-02 BMIN= 1.2500E-02 BPA= 0.00
if 'BMAJ' in history_str:
... | [
"def",
"search_beam",
"(",
"hdulist",
")",
":",
"header",
"=",
"hdulist",
"[",
"0",
"]",
".",
"header",
"history",
"=",
"header",
"[",
"'HISTORY'",
"]",
"history_str",
"=",
"str",
"(",
"history",
")",
"#AIPS CLEAN BMAJ= 1.2500E-02 BMIN= 1.2500E-02 BPA= 0.00"... | Will search the beam info from the HISTORY
:param hdulist:
:return: | [
"Will",
"search",
"the",
"beam",
"info",
"from",
"the",
"HISTORY",
":",
"param",
"hdulist",
":",
":",
"return",
":"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/scripts/fix_beam.py#L22-L35 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | fix_shape | def fix_shape(source):
"""
Ensure that a>=b for a given source object.
If a<b then swap a/b and increment pa by 90.
err_a/err_b are also swapped as needed.
Parameters
----------
source : object
any object with a/b/pa/err_a/err_b properties
"""
if source.a < source.b:
... | python | def fix_shape(source):
"""
Ensure that a>=b for a given source object.
If a<b then swap a/b and increment pa by 90.
err_a/err_b are also swapped as needed.
Parameters
----------
source : object
any object with a/b/pa/err_a/err_b properties
"""
if source.a < source.b:
... | [
"def",
"fix_shape",
"(",
"source",
")",
":",
"if",
"source",
".",
"a",
"<",
"source",
".",
"b",
":",
"source",
".",
"a",
",",
"source",
".",
"b",
"=",
"source",
".",
"b",
",",
"source",
".",
"a",
"source",
".",
"err_a",
",",
"source",
".",
"err... | Ensure that a>=b for a given source object.
If a<b then swap a/b and increment pa by 90.
err_a/err_b are also swapped as needed.
Parameters
----------
source : object
any object with a/b/pa/err_a/err_b properties | [
"Ensure",
"that",
"a",
">",
"=",
"b",
"for",
"a",
"given",
"source",
"object",
".",
"If",
"a<b",
"then",
"swap",
"a",
"/",
"b",
"and",
"increment",
"pa",
"by",
"90",
".",
"err_a",
"/",
"err_b",
"are",
"also",
"swapped",
"as",
"needed",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1786-L1802 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | theta_limit | def theta_limit(theta):
"""
Angle theta is periodic with period pi.
Constrain theta such that -pi/2<theta<=pi/2.
Parameters
----------
theta : float
Input angle.
Returns
-------
theta : float
Rotate angle.
"""
while theta <= -1 * np.pi / 2:
theta += ... | python | def theta_limit(theta):
"""
Angle theta is periodic with period pi.
Constrain theta such that -pi/2<theta<=pi/2.
Parameters
----------
theta : float
Input angle.
Returns
-------
theta : float
Rotate angle.
"""
while theta <= -1 * np.pi / 2:
theta += ... | [
"def",
"theta_limit",
"(",
"theta",
")",
":",
"while",
"theta",
"<=",
"-",
"1",
"*",
"np",
".",
"pi",
"/",
"2",
":",
"theta",
"+=",
"np",
".",
"pi",
"while",
"theta",
">",
"np",
".",
"pi",
"/",
"2",
":",
"theta",
"-=",
"np",
".",
"pi",
"retur... | Angle theta is periodic with period pi.
Constrain theta such that -pi/2<theta<=pi/2.
Parameters
----------
theta : float
Input angle.
Returns
-------
theta : float
Rotate angle. | [
"Angle",
"theta",
"is",
"periodic",
"with",
"period",
"pi",
".",
"Constrain",
"theta",
"such",
"that",
"-",
"pi",
"/",
"2<theta<",
"=",
"pi",
"/",
"2",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1827-L1846 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | scope2lat | def scope2lat(telescope):
"""
Convert a telescope name into a latitude
returns None when the telescope is unknown.
Parameters
----------
telescope : str
Acronym (name) of telescope, eg MWA.
Returns
-------
lat : float
The latitude of the telescope.
Notes
--... | python | def scope2lat(telescope):
"""
Convert a telescope name into a latitude
returns None when the telescope is unknown.
Parameters
----------
telescope : str
Acronym (name) of telescope, eg MWA.
Returns
-------
lat : float
The latitude of the telescope.
Notes
--... | [
"def",
"scope2lat",
"(",
"telescope",
")",
":",
"scopes",
"=",
"{",
"'MWA'",
":",
"-",
"26.703319",
",",
"\"ATCA\"",
":",
"-",
"30.3128",
",",
"\"VLA\"",
":",
"34.0790",
",",
"\"LOFAR\"",
":",
"52.9088",
",",
"\"KAT7\"",
":",
"-",
"30.721",
",",
"\"MEE... | Convert a telescope name into a latitude
returns None when the telescope is unknown.
Parameters
----------
telescope : str
Acronym (name) of telescope, eg MWA.
Returns
-------
lat : float
The latitude of the telescope.
Notes
-----
These values were taken from w... | [
"Convert",
"a",
"telescope",
"name",
"into",
"a",
"latitude",
"returns",
"None",
"when",
"the",
"telescope",
"is",
"unknown",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1849-L1898 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | check_cores | def check_cores(cores):
"""
Determine how many cores we are able to use.
Return 1 if we are not able to make a queue via pprocess.
Parameters
----------
cores : int
The number of cores that are requested.
Returns
-------
cores : int
The number of cores available.
... | python | def check_cores(cores):
"""
Determine how many cores we are able to use.
Return 1 if we are not able to make a queue via pprocess.
Parameters
----------
cores : int
The number of cores that are requested.
Returns
-------
cores : int
The number of cores available.
... | [
"def",
"check_cores",
"(",
"cores",
")",
":",
"cores",
"=",
"min",
"(",
"multiprocessing",
".",
"cpu_count",
"(",
")",
",",
"cores",
")",
"if",
"six",
".",
"PY3",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"\"Aegean\"",
")",
"log",
".",
"info... | Determine how many cores we are able to use.
Return 1 if we are not able to make a queue via pprocess.
Parameters
----------
cores : int
The number of cores that are requested.
Returns
-------
cores : int
The number of cores available. | [
"Determine",
"how",
"many",
"cores",
"we",
"are",
"able",
"to",
"use",
".",
"Return",
"1",
"if",
"we",
"are",
"not",
"able",
"to",
"make",
"a",
"queue",
"via",
"pprocess",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1901-L1931 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | get_aux_files | def get_aux_files(basename):
"""
Look for and return all the aux files that are associated witht this filename.
Will look for:
background (_bkg.fits)
rms (_rms.fits)
mask (.mim)
catalogue (_comp.fits)
psf map (_psf.fits)
will return filenames if they exist, or None ... | python | def get_aux_files(basename):
"""
Look for and return all the aux files that are associated witht this filename.
Will look for:
background (_bkg.fits)
rms (_rms.fits)
mask (.mim)
catalogue (_comp.fits)
psf map (_psf.fits)
will return filenames if they exist, or None ... | [
"def",
"get_aux_files",
"(",
"basename",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"basename",
")",
"[",
"0",
"]",
"files",
"=",
"{",
"\"bkg\"",
":",
"base",
"+",
"\"_bkg.fits\"",
",",
"\"rms\"",
":",
"base",
"+",
"\"_rms.fits\"",... | Look for and return all the aux files that are associated witht this filename.
Will look for:
background (_bkg.fits)
rms (_rms.fits)
mask (.mim)
catalogue (_comp.fits)
psf map (_psf.fits)
will return filenames if they exist, or None where they do not.
Parameters
--... | [
"Look",
"for",
"and",
"return",
"all",
"the",
"aux",
"files",
"that",
"are",
"associated",
"witht",
"this",
"filename",
".",
"Will",
"look",
"for",
":",
"background",
"(",
"_bkg",
".",
"fits",
")",
"rms",
"(",
"_rms",
".",
"fits",
")",
"mask",
"(",
"... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1934-L1966 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder._gen_flood_wrap | def _gen_flood_wrap(self, data, rmsimg, innerclip, outerclip=None, domask=False):
"""
Generator function.
Segment an image into islands and return one island at a time.
Needs to work for entire image, and also for components within an island.
Parameters
----------
... | python | def _gen_flood_wrap(self, data, rmsimg, innerclip, outerclip=None, domask=False):
"""
Generator function.
Segment an image into islands and return one island at a time.
Needs to work for entire image, and also for components within an island.
Parameters
----------
... | [
"def",
"_gen_flood_wrap",
"(",
"self",
",",
"data",
",",
"rmsimg",
",",
"innerclip",
",",
"outerclip",
"=",
"None",
",",
"domask",
"=",
"False",
")",
":",
"if",
"outerclip",
"is",
"None",
":",
"outerclip",
"=",
"innerclip",
"# compute SNR image (data has alrea... | Generator function.
Segment an image into islands and return one island at a time.
Needs to work for entire image, and also for components within an island.
Parameters
----------
data : 2d-array
Image array.
rmsimg : 2d-array
Noise image.
... | [
"Generator",
"function",
".",
"Segment",
"an",
"image",
"into",
"islands",
"and",
"return",
"one",
"island",
"at",
"a",
"time",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L83-L154 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder.estimate_lmfit_parinfo | def estimate_lmfit_parinfo(self, data, rmsimg, curve, beam, innerclip, outerclip=None, offsets=(0, 0),
max_summits=None):
"""
Estimates the number of sources in an island and returns initial parameters for the fit as well as
limits on those parameters.
Par... | python | def estimate_lmfit_parinfo(self, data, rmsimg, curve, beam, innerclip, outerclip=None, offsets=(0, 0),
max_summits=None):
"""
Estimates the number of sources in an island and returns initial parameters for the fit as well as
limits on those parameters.
Par... | [
"def",
"estimate_lmfit_parinfo",
"(",
"self",
",",
"data",
",",
"rmsimg",
",",
"curve",
",",
"beam",
",",
"innerclip",
",",
"outerclip",
"=",
"None",
",",
"offsets",
"=",
"(",
"0",
",",
"0",
")",
",",
"max_summits",
"=",
"None",
")",
":",
"debug_on",
... | Estimates the number of sources in an island and returns initial parameters for the fit as well as
limits on those parameters.
Parameters
----------
data : 2d-array
(sub) image of flux values. Background should be subtracted.
rmsimg : 2d-array
Image of 1... | [
"Estimates",
"the",
"number",
"of",
"sources",
"in",
"an",
"island",
"and",
"returns",
"initial",
"parameters",
"for",
"the",
"fit",
"as",
"well",
"as",
"limits",
"on",
"those",
"parameters",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L159-L386 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder.result_to_components | def result_to_components(self, result, model, island_data, isflags):
"""
Convert fitting results into a set of components
Parameters
----------
result : lmfit.MinimizerResult
The fitting results.
model : lmfit.Parameters
The model that was fit.
... | python | def result_to_components(self, result, model, island_data, isflags):
"""
Convert fitting results into a set of components
Parameters
----------
result : lmfit.MinimizerResult
The fitting results.
model : lmfit.Parameters
The model that was fit.
... | [
"def",
"result_to_components",
"(",
"self",
",",
"result",
",",
"model",
",",
"island_data",
",",
"isflags",
")",
":",
"global_data",
"=",
"self",
".",
"global_data",
"# island data",
"isle_num",
"=",
"island_data",
".",
"isle_num",
"idata",
"=",
"island_data",
... | Convert fitting results into a set of components
Parameters
----------
result : lmfit.MinimizerResult
The fitting results.
model : lmfit.Parameters
The model that was fit.
island_data : :class:`AegeanTools.models.IslandFittingData`
Data abou... | [
"Convert",
"fitting",
"results",
"into",
"a",
"set",
"of",
"components"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L388-L603 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder.load_globals | def load_globals(self, filename, hdu_index=0, bkgin=None, rmsin=None, beam=None, verb=False, rms=None, bkg=None, cores=1,
do_curve=True, mask=None, lat=None, psf=None, blank=False, docov=True, cube_index=None):
"""
Populate the global_data object by loading or calculating the variou... | python | def load_globals(self, filename, hdu_index=0, bkgin=None, rmsin=None, beam=None, verb=False, rms=None, bkg=None, cores=1,
do_curve=True, mask=None, lat=None, psf=None, blank=False, docov=True, cube_index=None):
"""
Populate the global_data object by loading or calculating the variou... | [
"def",
"load_globals",
"(",
"self",
",",
"filename",
",",
"hdu_index",
"=",
"0",
",",
"bkgin",
"=",
"None",
",",
"rmsin",
"=",
"None",
",",
"beam",
"=",
"None",
",",
"verb",
"=",
"False",
",",
"rms",
"=",
"None",
",",
"bkg",
"=",
"None",
",",
"co... | Populate the global_data object by loading or calculating the various components
Parameters
----------
filename : str or HDUList
Main image which source finding is run on
hdu_index : int
HDU index of the image within the fits file, default is 0 (first)
... | [
"Populate",
"the",
"global_data",
"object",
"by",
"loading",
"or",
"calculating",
"the",
"various",
"components"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L608-L742 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder.save_background_files | def save_background_files(self, image_filename, hdu_index=0, bkgin=None, rmsin=None, beam=None, rms=None, bkg=None, cores=1,
outbase=None):
"""
Generate and save the background and RMS maps as FITS files.
They are saved in the current directly as aegean-background.f... | python | def save_background_files(self, image_filename, hdu_index=0, bkgin=None, rmsin=None, beam=None, rms=None, bkg=None, cores=1,
outbase=None):
"""
Generate and save the background and RMS maps as FITS files.
They are saved in the current directly as aegean-background.f... | [
"def",
"save_background_files",
"(",
"self",
",",
"image_filename",
",",
"hdu_index",
"=",
"0",
",",
"bkgin",
"=",
"None",
",",
"rmsin",
"=",
"None",
",",
"beam",
"=",
"None",
",",
"rms",
"=",
"None",
",",
"bkg",
"=",
"None",
",",
"cores",
"=",
"1",
... | Generate and save the background and RMS maps as FITS files.
They are saved in the current directly as aegean-background.fits and aegean-rms.fits.
Parameters
----------
image_filename : str or HDUList
Input image.
hdu_index : int
If fits file has more th... | [
"Generate",
"and",
"save",
"the",
"background",
"and",
"RMS",
"maps",
"as",
"FITS",
"files",
".",
"They",
"are",
"saved",
"in",
"the",
"current",
"directly",
"as",
"aegean",
"-",
"background",
".",
"fits",
"and",
"aegean",
"-",
"rms",
".",
"fits",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L744-L822 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder.save_image | def save_image(self, outname):
"""
Save the image data.
This is probably only useful if the image data has been blanked.
Parameters
----------
outname : str
Name for the output file.
"""
hdu = self.global_data.img.hdu
hdu.data = self.g... | python | def save_image(self, outname):
"""
Save the image data.
This is probably only useful if the image data has been blanked.
Parameters
----------
outname : str
Name for the output file.
"""
hdu = self.global_data.img.hdu
hdu.data = self.g... | [
"def",
"save_image",
"(",
"self",
",",
"outname",
")",
":",
"hdu",
"=",
"self",
".",
"global_data",
".",
"img",
".",
"hdu",
"hdu",
".",
"data",
"=",
"self",
".",
"global_data",
".",
"img",
".",
"_pixels",
"hdu",
".",
"header",
"[",
"\"ORIGIN\"",
"]",... | Save the image data.
This is probably only useful if the image data has been blanked.
Parameters
----------
outname : str
Name for the output file. | [
"Save",
"the",
"image",
"data",
".",
"This",
"is",
"probably",
"only",
"useful",
"if",
"the",
"image",
"data",
"has",
"been",
"blanked",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L824-L843 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder._make_bkg_rms | def _make_bkg_rms(self, mesh_size=20, forced_rms=None, forced_bkg=None, cores=None):
"""
Calculate an rms image and a bkg image.
Parameters
----------
mesh_size : int
Number of beams per box default = 20
forced_rms : float
The rms of the image.
... | python | def _make_bkg_rms(self, mesh_size=20, forced_rms=None, forced_bkg=None, cores=None):
"""
Calculate an rms image and a bkg image.
Parameters
----------
mesh_size : int
Number of beams per box default = 20
forced_rms : float
The rms of the image.
... | [
"def",
"_make_bkg_rms",
"(",
"self",
",",
"mesh_size",
"=",
"20",
",",
"forced_rms",
"=",
"None",
",",
"forced_bkg",
"=",
"None",
",",
"cores",
"=",
"None",
")",
":",
"if",
"(",
"forced_rms",
"is",
"not",
"None",
")",
":",
"self",
".",
"log",
".",
... | Calculate an rms image and a bkg image.
Parameters
----------
mesh_size : int
Number of beams per box default = 20
forced_rms : float
The rms of the image.
If None: calculate the rms level (default).
Otherwise assume a constant rms.
... | [
"Calculate",
"an",
"rms",
"image",
"and",
"a",
"bkg",
"image",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L845-L956 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder._estimate_bkg_rms | def _estimate_bkg_rms(self, xmin, xmax, ymin, ymax):
"""
Estimate the background noise mean and RMS.
The mean is estimated as the median of data.
The RMS is estimated as the IQR of data / 1.34896.
Parameters
----------
xmin, xmax, ymin, ymax : int
The... | python | def _estimate_bkg_rms(self, xmin, xmax, ymin, ymax):
"""
Estimate the background noise mean and RMS.
The mean is estimated as the median of data.
The RMS is estimated as the IQR of data / 1.34896.
Parameters
----------
xmin, xmax, ymin, ymax : int
The... | [
"def",
"_estimate_bkg_rms",
"(",
"self",
",",
"xmin",
",",
"xmax",
",",
"ymin",
",",
"ymax",
")",
":",
"data",
"=",
"self",
".",
"global_data",
".",
"data_pix",
"[",
"ymin",
":",
"ymax",
",",
"xmin",
":",
"xmax",
"]",
"pixels",
"=",
"np",
".",
"ext... | Estimate the background noise mean and RMS.
The mean is estimated as the median of data.
The RMS is estimated as the IQR of data / 1.34896.
Parameters
----------
xmin, xmax, ymin, ymax : int
The bounding region over which the bkg/rms will be calculated.
Retu... | [
"Estimate",
"the",
"background",
"noise",
"mean",
"and",
"RMS",
".",
"The",
"mean",
"is",
"estimated",
"as",
"the",
"median",
"of",
"data",
".",
"The",
"RMS",
"is",
"estimated",
"as",
"the",
"IQR",
"of",
"data",
"/",
"1",
".",
"34896",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L958-L990 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder._load_aux_image | def _load_aux_image(self, image, auxfile):
"""
Load a fits file (bkg/rms/curve) and make sure that
it is the same shape as the main image.
Parameters
----------
image : :class:`AegeanTools.fits_image.FitsImage`
The main image that has already been loaded.
... | python | def _load_aux_image(self, image, auxfile):
"""
Load a fits file (bkg/rms/curve) and make sure that
it is the same shape as the main image.
Parameters
----------
image : :class:`AegeanTools.fits_image.FitsImage`
The main image that has already been loaded.
... | [
"def",
"_load_aux_image",
"(",
"self",
",",
"image",
",",
"auxfile",
")",
":",
"auximg",
"=",
"FitsImage",
"(",
"auxfile",
",",
"beam",
"=",
"self",
".",
"global_data",
".",
"beam",
")",
".",
"get_pixels",
"(",
")",
"if",
"auximg",
".",
"shape",
"!=",
... | Load a fits file (bkg/rms/curve) and make sure that
it is the same shape as the main image.
Parameters
----------
image : :class:`AegeanTools.fits_image.FitsImage`
The main image that has already been loaded.
auxfile : str or HDUList
The auxiliary file t... | [
"Load",
"a",
"fits",
"file",
"(",
"bkg",
"/",
"rms",
"/",
"curve",
")",
"and",
"make",
"sure",
"that",
"it",
"is",
"the",
"same",
"shape",
"as",
"the",
"main",
"image",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L992-L1015 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder._refit_islands | def _refit_islands(self, group, stage, outerclip=None, istart=0):
"""
Do island refitting (priorized fitting) on a group of islands.
Parameters
----------
group : list
A list of components grouped by island.
stage : int
Refitting stage.
... | python | def _refit_islands(self, group, stage, outerclip=None, istart=0):
"""
Do island refitting (priorized fitting) on a group of islands.
Parameters
----------
group : list
A list of components grouped by island.
stage : int
Refitting stage.
... | [
"def",
"_refit_islands",
"(",
"self",
",",
"group",
",",
"stage",
",",
"outerclip",
"=",
"None",
",",
"istart",
"=",
"0",
")",
":",
"global_data",
"=",
"self",
".",
"global_data",
"sources",
"=",
"[",
"]",
"data",
"=",
"global_data",
".",
"data_pix",
"... | Do island refitting (priorized fitting) on a group of islands.
Parameters
----------
group : list
A list of components grouped by island.
stage : int
Refitting stage.
outerclip : float
Ignored, placed holder for future development.
... | [
"Do",
"island",
"refitting",
"(",
"priorized",
"fitting",
")",
"on",
"a",
"group",
"of",
"islands",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1020-L1268 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder._fit_island | def _fit_island(self, island_data):
"""
Take an Island, do all the parameter estimation and fitting.
Parameters
----------
island_data : :class:`AegeanTools.models.IslandFittingData`
The island to be fit.
Returns
-------
sources : list
... | python | def _fit_island(self, island_data):
"""
Take an Island, do all the parameter estimation and fitting.
Parameters
----------
island_data : :class:`AegeanTools.models.IslandFittingData`
The island to be fit.
Returns
-------
sources : list
... | [
"def",
"_fit_island",
"(",
"self",
",",
"island_data",
")",
":",
"global_data",
"=",
"self",
".",
"global_data",
"# global data",
"dcurve",
"=",
"global_data",
".",
"dcurve",
"rmsimg",
"=",
"global_data",
".",
"rmsimg",
"# island data",
"isle_num",
"=",
"island_... | Take an Island, do all the parameter estimation and fitting.
Parameters
----------
island_data : :class:`AegeanTools.models.IslandFittingData`
The island to be fit.
Returns
-------
sources : list
The sources that were fit. | [
"Take",
"an",
"Island",
"do",
"all",
"the",
"parameter",
"estimation",
"and",
"fitting",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1270-L1370 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder._fit_islands | def _fit_islands(self, islands):
"""
Execute fitting on a list of islands
This function just wraps around fit_island, so that when we do multiprocesing
a single process will fit multiple islands before returning results.
Parameters
----------
islands : list of :... | python | def _fit_islands(self, islands):
"""
Execute fitting on a list of islands
This function just wraps around fit_island, so that when we do multiprocesing
a single process will fit multiple islands before returning results.
Parameters
----------
islands : list of :... | [
"def",
"_fit_islands",
"(",
"self",
",",
"islands",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Fitting group of {0} islands\"",
".",
"format",
"(",
"len",
"(",
"islands",
")",
")",
")",
"sources",
"=",
"[",
"]",
"for",
"island",
"in",
"islands",... | Execute fitting on a list of islands
This function just wraps around fit_island, so that when we do multiprocesing
a single process will fit multiple islands before returning results.
Parameters
----------
islands : list of :class:`AegeanTools.models.IslandFittingData`
... | [
"Execute",
"fitting",
"on",
"a",
"list",
"of",
"islands",
"This",
"function",
"just",
"wraps",
"around",
"fit_island",
"so",
"that",
"when",
"we",
"do",
"multiprocesing",
"a",
"single",
"process",
"will",
"fit",
"multiple",
"islands",
"before",
"returning",
"r... | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1372-L1394 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder.find_sources_in_image | def find_sources_in_image(self, filename, hdu_index=0, outfile=None, rms=None, bkg=None, max_summits=None, innerclip=5,
outerclip=4, cores=None, rmsin=None, bkgin=None, beam=None, doislandflux=False,
nopositive=False, nonegative=False, mask=None, lat=None, img... | python | def find_sources_in_image(self, filename, hdu_index=0, outfile=None, rms=None, bkg=None, max_summits=None, innerclip=5,
outerclip=4, cores=None, rmsin=None, bkgin=None, beam=None, doislandflux=False,
nopositive=False, nonegative=False, mask=None, lat=None, img... | [
"def",
"find_sources_in_image",
"(",
"self",
",",
"filename",
",",
"hdu_index",
"=",
"0",
",",
"outfile",
"=",
"None",
",",
"rms",
"=",
"None",
",",
"bkg",
"=",
"None",
",",
"max_summits",
"=",
"None",
",",
"innerclip",
"=",
"5",
",",
"outerclip",
"=",... | Run the Aegean source finder.
Parameters
----------
filename : str or HDUList
Image filename or HDUList.
hdu_index : int
The index of the FITS HDU (extension).
outfile : str
file for printing catalog (NOT a table, just a text file of my own... | [
"Run",
"the",
"Aegean",
"source",
"finder",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1396-L1540 | train |
PaulHancock/Aegean | AegeanTools/source_finder.py | SourceFinder.priorized_fit_islands | def priorized_fit_islands(self, filename, catalogue, hdu_index=0, outfile=None, bkgin=None, rmsin=None, cores=1,
rms=None, bkg=None, beam=None, lat=None, imgpsf=None, catpsf=None, stage=3, ratio=None, outerclip=3,
doregroup=True, docov=True, cube_index=None):
... | python | def priorized_fit_islands(self, filename, catalogue, hdu_index=0, outfile=None, bkgin=None, rmsin=None, cores=1,
rms=None, bkg=None, beam=None, lat=None, imgpsf=None, catpsf=None, stage=3, ratio=None, outerclip=3,
doregroup=True, docov=True, cube_index=None):
... | [
"def",
"priorized_fit_islands",
"(",
"self",
",",
"filename",
",",
"catalogue",
",",
"hdu_index",
"=",
"0",
",",
"outfile",
"=",
"None",
",",
"bkgin",
"=",
"None",
",",
"rmsin",
"=",
"None",
",",
"cores",
"=",
"1",
",",
"rms",
"=",
"None",
",",
"bkg"... | Take an input catalog, and image, and optional background/noise images
fit the flux and ra/dec for each of the given sources, keeping the morphology fixed
if doregroup is true the groups will be recreated based on a matching radius/probability.
if doregroup is false then the islands of the inpu... | [
"Take",
"an",
"input",
"catalog",
"and",
"image",
"and",
"optional",
"background",
"/",
"noise",
"images",
"fit",
"the",
"flux",
"and",
"ra",
"/",
"dec",
"for",
"each",
"of",
"the",
"given",
"sources",
"keeping",
"the",
"morphology",
"fixed"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/source_finder.py#L1542-L1782 | train |
PaulHancock/Aegean | AegeanTools/catalogs.py | check_table_formats | def check_table_formats(files):
"""
Determine whether a list of files are of a recognizable output type.
Parameters
----------
files : str
A list of file names
Returns
-------
result : bool
True if *all* the file names are supported
"""
cont = True
formats =... | python | def check_table_formats(files):
"""
Determine whether a list of files are of a recognizable output type.
Parameters
----------
files : str
A list of file names
Returns
-------
result : bool
True if *all* the file names are supported
"""
cont = True
formats =... | [
"def",
"check_table_formats",
"(",
"files",
")",
":",
"cont",
"=",
"True",
"formats",
"=",
"get_table_formats",
"(",
")",
"for",
"t",
"in",
"files",
".",
"split",
"(",
"','",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
... | Determine whether a list of files are of a recognizable output type.
Parameters
----------
files : str
A list of file names
Returns
-------
result : bool
True if *all* the file names are supported | [
"Determine",
"whether",
"a",
"list",
"of",
"files",
"are",
"of",
"a",
"recognizable",
"output",
"type",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/catalogs.py#L45-L69 | train |
PaulHancock/Aegean | AegeanTools/catalogs.py | show_formats | def show_formats():
"""
Print a list of all the file formats that are supported for writing.
The file formats are determined by their extensions.
Returns
-------
None
"""
fmts = {
"ann": "Kvis annotation",
"reg": "DS9 regions file",
"fits": "FITS Binary Table",
... | python | def show_formats():
"""
Print a list of all the file formats that are supported for writing.
The file formats are determined by their extensions.
Returns
-------
None
"""
fmts = {
"ann": "Kvis annotation",
"reg": "DS9 regions file",
"fits": "FITS Binary Table",
... | [
"def",
"show_formats",
"(",
")",
":",
"fmts",
"=",
"{",
"\"ann\"",
":",
"\"Kvis annotation\"",
",",
"\"reg\"",
":",
"\"DS9 regions file\"",
",",
"\"fits\"",
":",
"\"FITS Binary Table\"",
",",
"\"csv\"",
":",
"\"Comma separated values\"",
",",
"\"tab\"",
":",
"\"ta... | Print a list of all the file formats that are supported for writing.
The file formats are determined by their extensions.
Returns
-------
None | [
"Print",
"a",
"list",
"of",
"all",
"the",
"file",
"formats",
"that",
"are",
"supported",
"for",
"writing",
".",
"The",
"file",
"formats",
"are",
"determined",
"by",
"their",
"extensions",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/catalogs.py#L72-L97 | train |
PaulHancock/Aegean | AegeanTools/catalogs.py | update_meta_data | def update_meta_data(meta=None):
"""
Modify the metadata dictionary.
DATE, PROGRAM, and PROGVER are added/modified.
Parameters
----------
meta : dict
The dictionary to be modified, default = None (empty)
Returns
-------
An updated dictionary.
"""
if meta is None... | python | def update_meta_data(meta=None):
"""
Modify the metadata dictionary.
DATE, PROGRAM, and PROGVER are added/modified.
Parameters
----------
meta : dict
The dictionary to be modified, default = None (empty)
Returns
-------
An updated dictionary.
"""
if meta is None... | [
"def",
"update_meta_data",
"(",
"meta",
"=",
"None",
")",
":",
"if",
"meta",
"is",
"None",
":",
"meta",
"=",
"{",
"}",
"if",
"'DATE'",
"not",
"in",
"meta",
":",
"meta",
"[",
"'DATE'",
"]",
"=",
"strftime",
"(",
"\"%Y-%m-%d %H:%M:%S\"",
",",
"gmtime",
... | Modify the metadata dictionary.
DATE, PROGRAM, and PROGVER are added/modified.
Parameters
----------
meta : dict
The dictionary to be modified, default = None (empty)
Returns
-------
An updated dictionary. | [
"Modify",
"the",
"metadata",
"dictionary",
".",
"DATE",
"PROGRAM",
"and",
"PROGVER",
"are",
"added",
"/",
"modified",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/catalogs.py#L121-L142 | train |
PaulHancock/Aegean | AegeanTools/catalogs.py | save_catalog | def save_catalog(filename, catalog, meta=None, prefix=None):
"""
Save a catalogue of sources using filename as a model. Meta data can be written to some file types
(fits, votable).
Each type of source will be in a separate file:
- base_comp.ext :class:`AegeanTools.models.OutputSource`
- base_i... | python | def save_catalog(filename, catalog, meta=None, prefix=None):
"""
Save a catalogue of sources using filename as a model. Meta data can be written to some file types
(fits, votable).
Each type of source will be in a separate file:
- base_comp.ext :class:`AegeanTools.models.OutputSource`
- base_i... | [
"def",
"save_catalog",
"(",
"filename",
",",
"catalog",
",",
"meta",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"ascii_table_formats",
"=",
"{",
"'csv'",
":",
"'csv'",
",",
"'tab'",
":",
"'tab'",
",",
"'tex'",
":",
"'latex'",
",",
"'html'",
":"... | Save a catalogue of sources using filename as a model. Meta data can be written to some file types
(fits, votable).
Each type of source will be in a separate file:
- base_comp.ext :class:`AegeanTools.models.OutputSource`
- base_isle.ext :class:`AegeanTools.models.IslandSource`
- base_simp.ext :cla... | [
"Save",
"a",
"catalogue",
"of",
"sources",
"using",
"filename",
"as",
"a",
"model",
".",
"Meta",
"data",
"can",
"be",
"written",
"to",
"some",
"file",
"types",
"(",
"fits",
"votable",
")",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/catalogs.py#L145-L194 | train |
PaulHancock/Aegean | AegeanTools/catalogs.py | load_catalog | def load_catalog(filename):
"""
Load a catalogue and extract the source positions (only)
Parameters
----------
filename : str
Filename to read. Supported types are csv, tab, tex, vo, vot, and xml.
Returns
-------
catalogue : list
A list of [ (ra, dec), ...]
"""
... | python | def load_catalog(filename):
"""
Load a catalogue and extract the source positions (only)
Parameters
----------
filename : str
Filename to read. Supported types are csv, tab, tex, vo, vot, and xml.
Returns
-------
catalogue : list
A list of [ (ra, dec), ...]
"""
... | [
"def",
"load_catalog",
"(",
"filename",
")",
":",
"supported",
"=",
"get_table_formats",
"(",
")",
"fmt",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"-",
"1",
"]",
"[",
"1",
":",
"]",
".",
"lower",
"(",
")",
"# extension sans... | Load a catalogue and extract the source positions (only)
Parameters
----------
filename : str
Filename to read. Supported types are csv, tab, tex, vo, vot, and xml.
Returns
-------
catalogue : list
A list of [ (ra, dec), ...] | [
"Load",
"a",
"catalogue",
"and",
"extract",
"the",
"source",
"positions",
"(",
"only",
")"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/catalogs.py#L197-L236 | train |
PaulHancock/Aegean | AegeanTools/catalogs.py | load_table | def load_table(filename):
"""
Load a table from a given file.
Supports csv, tab, tex, vo, vot, xml, fits, and hdf5.
Parameters
----------
filename : str
File to read
Returns
-------
table : Table
Table of data.
"""
supported = get_table_formats()
fmt =... | python | def load_table(filename):
"""
Load a table from a given file.
Supports csv, tab, tex, vo, vot, xml, fits, and hdf5.
Parameters
----------
filename : str
File to read
Returns
-------
table : Table
Table of data.
"""
supported = get_table_formats()
fmt =... | [
"def",
"load_table",
"(",
"filename",
")",
":",
"supported",
"=",
"get_table_formats",
"(",
")",
"fmt",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"-",
"1",
"]",
"[",
"1",
":",
"]",
".",
"lower",
"(",
")",
"# extension sans '... | Load a table from a given file.
Supports csv, tab, tex, vo, vot, xml, fits, and hdf5.
Parameters
----------
filename : str
File to read
Returns
-------
table : Table
Table of data. | [
"Load",
"a",
"table",
"from",
"a",
"given",
"file",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/catalogs.py#L239-L269 | train |
PaulHancock/Aegean | AegeanTools/catalogs.py | write_table | def write_table(table, filename):
"""
Write a table to a file.
Parameters
----------
table : Table
Table to be written
filename : str
Destination for saving table.
Returns
-------
None
"""
try:
if os.path.exists(filename):
os.remove(file... | python | def write_table(table, filename):
"""
Write a table to a file.
Parameters
----------
table : Table
Table to be written
filename : str
Destination for saving table.
Returns
-------
None
"""
try:
if os.path.exists(filename):
os.remove(file... | [
"def",
"write_table",
"(",
"table",
",",
"filename",
")",
":",
"try",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"os",
".",
"remove",
"(",
"filename",
")",
"table",
".",
"write",
"(",
"filename",
")",
"log",
".",
"info"... | Write a table to a file.
Parameters
----------
table : Table
Table to be written
filename : str
Destination for saving table.
Returns
-------
None | [
"Write",
"a",
"table",
"to",
"a",
"file",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/catalogs.py#L272-L299 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.