Exemple #1
0
def main():
	if len(sys.argv) < 2 or len(sys.argv) > 3:
		print("invalid number of arguments")
		sys.exit(1)

	inp = sys.argv[1]
	out = None

	if len(sys.argv) == 3:
		out = sys.argv[2]

	with ap.io.fits.open(inp) as img:
		flx = utils.filter_img(img)
		plot_fft(flx, out)
Exemple #2
0
def main(fits, config):
	with open(config.maskfile) as mfile:
		# We reverse it from the "friendly" syntax to the coordinate-correct
		# version. Should we do this? Probably not. Do we care? Nope.
		mask = [[ch for ch in line.rstrip("\n")] for line in mfile][::-1]

		# Double check that the mask is valid.
		try:
			assert len(set(len(row) for row in mask)) == 1
		except AssertionError:
			raise ValueError("mask file must have equal length lines")

		# Create polygon based on mask.
		poly = polymask(mask)

	if config.track is not None:
		with open(config.track) as tfile:
			# TODO: Fix this by using the utils version?
			def parse_row(cadence, x, y):
				return (cadence, float(x), float(y))

			# TODO: Fix this by not using fieldnames=XYZ.
			rows = csv.DictReader(tfile)

			# First row specifies the polarity.
			_, mx, my = parse_row(**next(rows))
			track = np.array([{"cadence": cadence, "x": x*mx, "y": y*my} for (cadence, x, y) in (parse_row(**row) for row in rows)])

	with ap.io.fits.open(fits) as img:
		flximg = utils.filter_img(img, track=track, frame=config.maskframe)

		# XXX: We can fix this. It looks ghastly and only exists for animate.
		fig = plt.figure(figsize=flximg["FLUX"][0].shape[::-1], dpi=50)

		if config.plot_type == "ani":
			plot_ani(fig, flximg, aperture=poly, config=config)
		elif config.plot_type == "csv":
			if not config.ofile:
				raise ValueError("Must specify --save when using --csv.")
			out_csv(flximg, aperture=poly, config=config)
Exemple #3
0
def main(fits, plot_type, sigma=None, sigma_fraction=DEFAULT_FRACTION, **kwargs):
	fits = fits[0]
	with ap.io.fits.open(fits) as img:
		flximg = utils.filter_img(img)
		fig = plt.figure(figsize=flximg["FLUX"][0].shape[::-1], dpi=30)
		ax = fig.add_subplot(111)

		# XXX: This is sort of a horrible hack atm. It's very easily broken.
		if sigma is None:
			if sigma_fraction > 0:
				sigma = np.median([sigma_flux(flx, sigma_fraction) for flx in flximg["FLUX"]])
		kwargs["sigma"] = sigma

		if plot_type == "fft":
			plot_fft(ax, flximg, **kwargs)
			plt.show()
		elif plot_type == "lc":
			plot_lc(ax, flximg, **kwargs)
			plt.show()
		elif plot_type == "disp":
			# TODO: Let this be killed.
			plot_crop(flximg, **kwargs)