Пример #1
0
	def _pipeline_sparx(self, Xmol, src, pop, img, cnv, tmb, genimg=True):
		"""
		Pipeline for generating SPARX solutions
		"""
		# Calculate excitation
		if not exists(pop):
			#tasks.task_amc(source=src, molec='o-h2o_2lev', out=pop)
			utils.call("mpirun -np %d sparx --parallel run task_amc source='%s' molec='%s' out='%s' fixiter=10 lte=%s trace=%s nrays=%d snr=%.0f tolerance=%.2e maxiter=%d"%(NPROC, src, self.mol.name, pop, FROMLTE, TRACE, NRAYS, SNR, TOLERANCE, MAXITER))
			#utils.call("sparx run task_amc source='%s' molec='o-h2o_2lev' out='%s'"%(src, pop))

		if genimg:
			# Generate synthesized map
			if not exists(img):
				tasks.task_lineobs(
					source=pop,
					chan="[%d,'%gkms^-1']"%(self.chan_n, self.chan_width),
					dist="%gpc"%(self.dist / Unit.pc),
					line=0,
					out=img,
					npix="[256,256]",
					cell="['0.5asec','0.5asec']",
					unit="JY/PIXEL")

			# To avoid mysterious 'invalid argument' bug in miriad
			from time import sleep
			sleep(0.5)

			# Convolve with beam
			if not exists(cnv):
				miriad.convol(img, cnv, self.fwhm)

			# To avoid mysterious 'invalid argument' bug in miriad
			from time import sleep
			sleep(0.5)

			# Convert to brightness temperature
			if not exists(tmb):
				miriad.convert_flux_to_tb(cnv, tmb, self.freq, self.fwhm)
		return
Пример #2
0
		src3d = "%s.%s.src3d"%(name, molec)
		out3d = "%s.%s.xyv3d"%(name, molec)
		tau3d = "%s.%s.tau3d"%(name, molec)

		# Reset inputs (safer)
		inputs.reset_inputs()

		# Calculate analytical solution
		Tb_est, tau_est = Estimate(molec)

		# Generate model
		tasks.task_valline1d(out=src1d, molec=molec, xmol=1e-10)
		tasks.task_valline3d(out=src3d, molec=molec, xmol=1e-10)

		# Generate synthetic dust observations
		tasks.task_lineobs(source=src1d, out=out1d, tau=tau1d, line="0", cell="['0.5asec', '0.5asec']", unit='K', chan="[32, '0.2kms^-1']")
		tasks.task_lineobs(source=src3d, out=out3d, tau=tau3d, line="0", cell="['0.5asec', '0.5asec']", unit='K', chan="[32, '0.2kms^-1']")

		from subprocess import Popen, PIPE
		# Get brightness temperature
		p = Popen("imspec in=%s options=eformat,nohead region='rel,box(0,0,0,0)' plot=sum | head -n 18 | tail -n 1 | awk '{print $3}'"%out1d, shell=True, stdout=PIPE, stderr=PIPE)
		Tb_s1d = float(p.communicate()[0])
		p = Popen("imspec in=%s options=eformat,nohead region='rel,box(0,0,0,0)' plot=sum | head -n 18 | tail -n 1 | awk '{print $3}'"%out3d, shell=True, stdout=PIPE, stderr=PIPE)
		Tb_s3d = float(p.communicate()[0])

		# Get peak tau
		p = Popen("imspec in=%s options=eformat,nohead region='rel,box(0,0,0,0)' plot=sum | head -n 18 | tail -n 1 | awk '{print $3}'"%tau1d, shell=True, stdout=PIPE, stderr=PIPE)
		tau_s1d = float(p.communicate()[0])
		p = Popen("imspec in=%s options=eformat,nohead region='rel,box(0,0,0,0)' plot=sum | head -n 18 | tail -n 1 | awk '{print $3}'"%tau3d, shell=True, stdout=PIPE, stderr=PIPE)
		tau_s3d = float(p.communicate()[0])