Commit 9e2117bb authored by Patrick Clearwater's avatar Patrick Clearwater
Browse files

Python 2->3 on gstlal_postcoh_skymap2fits

parent c023b1f0
......@@ -21,7 +21,7 @@ Produce a fits file from binary sky map file
import struct
from import fits
from import fits
import numpy as np
import scipy as sp
import pdb
......@@ -127,12 +127,12 @@ nifo = len(instruments) / 2 # ifo e.g. H1, L1, len is 2
# read cohsnr^2, and nullsnr^2 for each sky direction
f = open(input_fname, 'rb')
for chunk in iter(lambda:, ''):
for chunk in iter(lambda:, b''):
allread_skymap.append(struct.unpack('f', chunk)[0])
# load cohsnrsq, and nullsnrsq
npix = len(allread_skymap) / 2
npix = int(len(allread_skymap) / 2)
cohsnrsq_skymap = allread_skymap[0:npix]
nullsnrsq_skymap = allread_skymap[npix:]
......@@ -142,11 +142,11 @@ nullsnrsq_skymap = allread_skymap[npix:]
xmldoc = utils.load_filename(opts.cuda_postcoh_detrsp_fname,
detrsp_start_time = long(
detrsp_start_time = int(
param_from_xmldoc(xmldoc, pipe_macro.DETRSP_XML_PARAM_NAME_GPS_START))
gps_step = long(
gps_step = int(
param_from_xmldoc(xmldoc, pipe_macro.DETRSP_XML_PARAM_NAME_GPS_STEP))
event_time = long(opts.event_time)
event_time = int(opts.event_time)
igps = find_closest_gps(event_time, detrsp_start_time, gps_step)
Det_name = "Det_map_gps_%d" % igps
Det_array = array_from_xmldoc(xmldoc, Det_name)
......@@ -21,13 +21,32 @@ except IndexError:
import pygtk
import gobject
import pygst
import gst
except AttributeError:
# according to the PyGobject documentation, threads_init isn't needed for
# modern versions, and after a certain point it seems to have been removed.
# So if we get an attribute error, presumably we are using one of those
# later versions and so can just eat it
# This is somewhat unsatisfactory conditional version check. If we're running
# under Python 3, then we won't be able to import pygst (because pygst is for
# gstreamer-0.10, but gstreamer 0.10 does not support Python 3). Then,
# subsequently, we won't be able to import anything below that except for the
# very basics.
# Thankfully, the only thing we actually need for gstlal_postcoh_skymap2fits is
# gstlal.pipemodules.pipe_macro, so we can (for now) gate the other imports
# behind a Python version check
import sys
if sys.version_info[0] == 2:
import pygst
import gst
from gstlal import pipeio
from gstlal import pipeparts
from gstlal import pipeio
from gstlal import pipeparts
from gstlal.pipemodules import pipe_macro
# SPIIR many instruments, many template banks
......@@ -154,7 +173,7 @@ def mkcohfar_accumbackground(pipeline,
if output_name is not None:
properties["output_name"] = output_name
print "source type %d" % source_type
print("source type %d" % source_type)
if "name" in properties:
elem = gst.element_factory_make("cohfar_accumbackground",
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment