Exemplo n.º 1
0
Arguments:
file_list - str - Name of (ASCII/txt) file with list of FITS observation files. 
	One file per line.

Written in Python 2.7 by A.L. Stevens, [email protected], 2014

get_keyword is available in my Git repository 'whizzy_scripts'
			
"""

##########################	
if __name__ == "__main__":
	pass
	parser = argparse.ArgumentParser()
	parser.add_argument('file_list', \
		help="Name of file with list of fits files of the observations.")
	args = parser.parse_args()

	input_files = [line.strip() for line in open(args.file_list)]
	
	total_time = 0
	for file in input_files:
		start_time = float(get_keyword.main(file, 0, 'TSTART'))
		stop_time = float(get_keyword.main(file, 0, 'TSTOP'))
		time = stop_time - start_time
		total_time += time
	
	print total_time # in seconds


## End of function 'total_obs_time'
Exemplo n.º 2
0
def get_epoch(fits_file):
	"""
			get_epoch
			
	Have this in a separate method so that it can return a value; useful when importing 
	this into other programs.
			
	Passed: fits_file - str - Name of an RXTE observation FITS file.
	
	Returns: epoch - int - The RXTE observation epoch of the FITS observation file.
	
	"""
	pass
	
	obs_time = get_keyword.main(fits_file, 0, 'DATE-OBS')
	print "DATE-OBS =", obs_time
	print "Length of DATE-OBS =", len(obs_time)
	year = -1
	month = -1
	day = -1
	if len(obs_time) == 8:
		day = int(obs_time[0:2])
		print "Day =", day
		month = int(obs_time[3:5])
		print "Month =", month
		year = obs_time[6:8]
		if year[0] == '9':
			year = int("19"+year)
		else:
			year = int("20"+year)
		print "Year =", year
	elif len(obs_time) == 19:
		year = int(obs_time[0:4])
		print "Year =", year
		month = int(obs_time[5:7])
		print "Month =", month
		day = int(obs_time[8:10])
		print "Day =", day
	else:
		print "\tERROR: Format of date is not understood."
		return 0
		
	assert (year >= 1995 and year <= 2012) ## Making sure that the date is actually when 
										   ##  RXTE was operational
	
	## Determining which epoch the date falls in
	
	if (year is -1) or (month is -1) or (day is -1):
		print "\tERROR: Month, date, or year not properly assigned."
		return 0
	
	## This will be easier if I just use MJD...
	##  but need to convert TT to MJD which is too big a headache for now...
	
	if year == 1995: 
		return 1
		
	elif year == 1996:
		if month < 3:
			return 1
		elif month == 3:
			if day < 3: return 1
			elif day == 3: return 0 ## Need to check times
			else: return 2
		elif month == 4:
			if day < 15: return 2
			elif day == 15: return 0 ## Need to check times
			else: return 3
		else:
			return 3
		
	elif year == 1997 or year == 1998:
		return 3
	
	elif year == 1999:
		if month < 3:
			return 3
		elif month == 3:
			if day < 22: return 3
			elif day == 22: return 0 ## Need to check times
			else: return 4
		else: 
			return 4
		
	elif year == 2000:
		if month < 5:
			return 4
		elif month == 5:
			if day < 13: return 4
			elif day == 13: return 0 ## Need to check times
			else: return 5
		else:
			return 5
		
	else:
		return 5