Пример #1
0
def make_pngs(clist):
	'''
	Get all the images from yesterday and make pngs 
	for the daily montage. PNGs will be stored in 
	
	/ngts/dasXX/movie/ 
	
	These will be removed each day once the movie is made
	'''
	if me=='ops':
		# connect to database
		conn=pymysql.connect(host='ds',db='ngts_ops')
		cur=conn.cursor()
		
		# get the actions from yesterday
		qry="SELECT action_id,camera_id,action FROM action_list WHERE schedule_start_utc BETWEEN date_sub(now(), INTERVAL 1 DAY) AND now()"
		cur.execute(qry)
			
		# get the action ids for each camera (and dome 899)
		for row in cur:
			if row[2] != 'stow':
				cams[row[1]].append("action%s_%s" % (row[0],row[2]))
		
	if me=='James':
		for i in cams:
			cams[i].append('action100000_focusSweep')
	
	# remove the roof entry, not needed
	del cams[899]
	
	# now we have the action ids go through and create the images for each 
	for i in cams:
		# only do those listed on command line
		if str(i) in clist:
			if len(cams[i]) > 0 and das[i] != None:
				if os.path.exists(movie_dir) == False:
					os.mkdir(movie_dir)	
				logger.info(movie_dir)
				for j in cams[i]:
					logger.info("%s%s/%s/*.fits" % (top_dir,das[i],j))
					t=sorted(g.glob('%s%s/%s/*.fits' % (top_dir,das[i],j)))
					
					camera_movie_dir=movie_dir+das[i]
					create_movie(t,images_directory=camera_movie_dir,include_increment=False,
						clobber_images_directory=False,resize_factor=4)
			else:
				logger.warn('No images for %d' % (i))
		else:
			continue
Пример #2
0
		if row[3] != 'stow':
			cams[row[1]].append("action%s_%s" % (row[2],row[3]))
	
	if len(cams[cam]) > 0 and cam != 899:
		# go into the last action directory
		if das[cam] != None:
			os.chdir("%s/%s" % (das[cam],cams[cam][-1]))
			logger.info("Moving to %s/%s" % (das[cam],cams[cam][-1]))
			# get the last image
			t=sorted(g.glob('*.fits'))
			
			if len(t)>0:
			 	pngfile="%s.png" % (t[-1])
				logger.info("PNG file to make is %s.png" % (t[-1]))
			 	if pngfile not in os.listdir('%s/last_imgs/%s/' % (cron_dir,cam)):
					create_movie([t[-1]],images_directory='%s/last_imgs/%s' % (cron_dir,cam),
						no_time_series=True,include_increment=False,clobber_images_directory=False,resize_factor=4)
				
					here=os.getcwd()
					os.chdir("%s/last_imgs/%s" % (cron_dir,cam))
					logger.info("Moving to %s/last_imgs/%s" % (cron_dir,cam))
					
					try:
						f=open('last_img.log').readline()
					except IOError:
						f="XXX"
					logger.info("Last image: %s" % (f))
					
					if f != pngfile:
						os.system('cp %s %s/cam_%s.png' % (pngfile,web_dir,cam))
						logger.info("Copying %s to %s/cam_%s.png" % (pngfile,web_dir,cam))
						f3=open('last_img.log','w')