Commit 22dee6f8 authored by Caillat Michel's avatar Caillat Michel
Browse files

Work in progress

parent 995351d9
......@@ -344,46 +344,41 @@ class DataBlock:
self.__logger.debug("__getFreqsAtiRAiDEC: exiting")
return result
def __getSumOverSliceRectArea_0(self, sliceIndex, RAPix0=None, RAPix1=None, DECPix0=None, DECPix1=None):
def __getSumOverSliceRectArea_0(self, iFREQ, iRA0=None, iRA1=None, iDEC0=None, iDEC1=None):
self.__logger.debug("__getSumOverSliceRectArea_0: entering")
with_dask=True
if with_dask:
x = (dask.array.nansum(self.__data[sliceIndex, DECPix0:DECPix1, RAPix0:RAPix1]) / self.__convert * self.__cdelt).compute().tolist()
x = (dask.array.nansum(self.__data[iFREQ, iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt).compute().tolist()
else:
x = np.nansum(self.__data[sliceIndex, DECPix0:DECPix1, RAPix0:RAPix1]) / self.__convert * self.__cdelt
x = np.nansum(self.__data[iFREQ, iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt
self.__logger.debug("__getSumOverSliceRectArea__0: exiting")
return x
def __getAverage_0(self, step, startZ=None, endZ=None, startY=None, endY=None, startX=None, endX=None):
def __getAverage_0(self, iFREQ0=None, iFREQ1=None, iDEC0=None, iDEC1=None, iRA0=None, iRA1=None):
self.__logger.debug("__getAverage_0: entering")
self.__logger.debug("Getting average.")
self.__logger.debug("shape length: %d" % len(self.__data.shape))
if startX == None:
startX = 0
if endX == None:
endX = self.__data.shape[2]
if startY == None:
startY = 0
if endY == None:
endY = self.__data.shape[1]
if startZ == None:
startZ = 0
else:
startZ = int(startZ)
if endZ == None:
endZ = self.__data.shape[0]
else:
endZ = int(endZ)
if iRA0 == None:
iRA0 = 0
if iRA1 == None:
iRA1 = self.__data.shape[2]
if iDEC0 == None:
iDEC0 = 0
if iDEC1 == None:
iDEC1 = self.__data.shape[1]
if iFREQ0 == None:
iFREQ0 = 0
if iFREQ1 == None:
iFREQ1 = self.__data.shape[0]
self.__logger.debug(f"{iFREQ0}, {iFREQ1}, {iDEC0}, {iDEC1}, {iRA0}, {iRA1}")
if self.__data.shape[0] == 1:
res = self.__data
self.__logger.debug("Returning")
return res
res = [[]] * endY
res = [[]] * (iDEC1 - iDEC0 + 1)
if (self.__header["ORIGIN"]=="GILDAS Consortium"):
self.__logger.debug("Gildas data")
......@@ -403,26 +398,25 @@ class DataBlock:
else:
cdelt = 0.0
self.__logger.debug("startZ= %d, endZ=%d" % (startZ, endZ))
self.__logger.debug("slice sum begin")
with_dask = True
if with_dask:
res = (dask.array.nansum(self.__data[startZ:endZ, startY:endY, startX:endX], 0)*cdelt).compute()
res = (dask.array.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt).compute()
else:
res = np.nansum(self.__data[startZ:endZ, startY:endY, startX:endX], 0)
res = np.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt
self.__logger.debug("slice sum end")
self.__logger.debug("__getAverage_0: exiting")
self.__logger.debug(f"res={res}")
return res
def __getPercentile(self, a, percent):
return np.nanpercentile(a, percent)
def __convertOneSlice2PNG(self, PNGPath, sliceIndex, sliceData, transformation_name, palette_name, video_mode_name):
def __convertOneSlice2PNG(self, PNGPath, iFREQ, sliceData, transformation_name, palette_name, video_mode_name):
self.__logger.debug("__convertOneSlice2PNG: entering")
self.__logger.debug("__convertOneSlice2PNG: exiting")
return self.__convertOneSlice2PNG_0(PNGPath, sliceIndex, sliceData, transformation_name, palette_name, video_mode_name)
return self.__convertOneSlice2PNG_0(PNGPath, iFREQ, sliceData, transformation_name, palette_name, video_mode_name)
def __convertOneSlice2PNG_0 (self, PNGPath, sliceData, transformation_name, palette_name, video_mode_name):
self.__logger.debug("__convertOneSlice2PNG_0: entering")
......@@ -505,9 +499,9 @@ class DataBlock:
self.__logger.debug("__convertOneSlice2PNG_0: exiting")
return data_steps
def __convertSummedSliceRange2PNG(self, sliceIndex0, sliceIndex1, sliceData, transformation_name, palette_name, video_mode_name):
def __convertSummedSliceRange2PNG(self, iFREQ0, iFREQ1, sliceData, transformation_name, palette_name, video_mode_name):
self.__logger.debug("__convertSummedSliceRange2PNG: entering")
PNGPath = "%s/%d-%d.%s.%s.%s.png" % (self.__PNGDir, sliceIndex0, sliceIndex1, transformation_name, palette_name, video_mode_name)
PNGPath = "%s/%d-%d.%s.%s.%s.png" % (self.__PNGDir, iFREQ0, iFREQ1, transformation_name, palette_name, video_mode_name)
return self.__convertOneSlice2PNG_0(PNGPath, sliceData, transformation_name, palette_name, video_mode_name)
self.__logger.debug("__convertSummedSliceRange2PNG: exiting")
......@@ -634,9 +628,8 @@ class DataBlock:
def getDimensions(self):
return {"status": True, "message": "", "result": self.__data.shape}
def getSlice(self, sliceNumb, step):
def getSlice(self, iFREQ, step=1):
self.__logger.debug("getSlice: entering")
self.__logger.debug( "getting slice: %d of %s with shape %r" % (sliceNumb, self.__relFITSFilePath, self.__data.shape))
numDimensions = len(self.__data.shape)
result = dict()
......@@ -650,7 +643,7 @@ class DataBlock:
if numDimensions == 2:
x = self.__data[0:self.__data.shape[0]:step, 0:self.__data.shape[1]:step]
elif numDimensions == 3:
x = self.__data[sliceNumb, 0:self.__data.shape[1]:step, 0:self.__data.shape[2]:step]
x = self.__data[iFREQ, 0:self.__data.shape[1]:step, 0:self.__data.shape[2]:step]
self.__logger.debug(f"type self.__data = {type(self.__data)}, type x = {type(x)}")
self.__logger.debug("Avant isnan")
self.__logger.debug(x.shape)
......@@ -670,21 +663,19 @@ class DataBlock:
self.__logger.debug("getSlice: exiting")
return result
def getFreq(self, x=None, y=None, startZ=None, endZ=None):
# y x ou x y
def getFreq(self, iRA=None, iDEC=None, iFREQ0=None, iFREQ1=None):
self.__logger.debug( "getFreq: entering")
if x == None:
x = 0
if y == None:
y = 0
if startZ == None:
startZ = 0
if endZ == None:
endZ = self.__data.shape[0]
nonanArray = np.nan_to_num(self.__data[startZ:endZ, y, x].compute())
if iRA == None:
iRA = 0
if iDEC == None:
iDEC = 0
if iFREQ0 == None:
iFREQ0 = 0
if iFREQ1 == None:
iFREQ1 = self.__data.shape[0]
nonanArray = np.nan_to_num(self.__data[iFREQ0:iFREQ1, iDEC, iRA].compute())
result = nonanArray.tolist()
self.__logger.debug("Position: %d %d, length of result %d" % (x, y, len(result)))
self.__logger.debug( "getFreq: exiting")
return {"status": True, "message": "", "result": result}
......@@ -704,32 +695,28 @@ class DataBlock:
self.__logger.debug("getPixelValueAtiFreqiRAiDEC: exiting")
return result
def getAverageSpectrum(self, startY=None, endY=None, startX=None, endX=None, retFITS=False):
def getAverageSpectrum(self, iDEC0=None, iDEC1=None, iRA0=None, iRA1=None, retFITS=False):
self.__logger.debug("getAverageSpectrum: entering")
startZ = 0
endZ = self.__data.shape[0]
if startX == None:
startX = 0
if endX == None:
endX = self.__data.shape[2]
if startY == None:
startY = 0
if endY == None:
endY = self.__data.shape[1]
self.__logger.debug("%d %d %d %d" % (startX, endX, startY, endY))
self.__logger.debug("%s %s %s %s" % (type(startX), type(endX), type(startY), type(endY)))
if iRA0 == None:
iRA0 = 0
if iRA1 == None:
iRA1 = self.__data.shape[2]
if iDEC0 == None:
iDEC0 = 0
if iDEC1 == None:
iDEC1 = self.__data.shape[1]
pi180 = math.pi / 180 / 4.86e-6
averageSpectrum = None
with_dask=True
if with_dask:
averageSpectrum = (dask.array.nansum(self.__data[:, startY:endY, startX:endX], (1,2)) / self.__convert * self.__cdelt).compute().tolist()
averageSpectrum = (dask.array.nansum(self.__data[:, iDEC0:iDEC1, iRA0:iRA1], (1,2)) / self.__convert * self.__cdelt).compute().tolist()
else:
averageSpectrum = np.nansum(self.__data[:, startY:endY, startX:endX], (1,2)) / self.__convert * self.__cdelt
averageSpectrum = np.nansum(self.__data[:, iDEC0:iDEC1, iRA0:iRA1], (1,2)) / self.__convert * self.__cdelt
if retFITS:
crds = self.__getFreqsAtiRAiDEC(startX, startY)
crds = self.__getFreqsAtiRAiDEC(iRA0, iDEC0)
averageSpectrumFits = self.__createFITSSpectrumFromData(crds,self.__header["CUNIT3"], averageSpectrum, "Jy")
result = {"averageSpectrum": averageSpectrum, "averageSpectrumFits": averageSpectrumFits}
else:
......@@ -739,23 +726,23 @@ class DataBlock:
self.__logger.debug("getAverageSpectrum: exiting")
return result
def getSumOverSliceRectArea(self, sliceIndex, RAPix0=None, RAPix1=None, DECPix0=None, DECPix1=None):
def getSumOverSliceRectArea(self, iFREQ, iRA0=None, iRA1=None, iDEC0=None, iDEC1=None):
self.__logger.debug("getSumOnSliceRectArea: entering")
if (len(self.__data.shape) == 2 and sliceIndex >= 1) or (len(self.__data.shape) == 3 and sliceIndex >= self.__data.shape[0]):
result = {"status": False, "message": "Invalid slice index '%d'." % (sliceIndex), "result": None }
if (len(self.__data.shape) == 2 and iFREQ >= 1) or (len(self.__data.shape) == 3 and iFREQ >= self.__data.shape[0]):
result = {"status": False, "message": "Invalid slice index '%d'." % (iFREQ), "result": None }
else:
result = {"status": True, "message": "", "result": self.__getSumOverSliceRectArea_0(sliceIndex, RAPix0, RAPix1, DECPix0, DECPix1)}
result = {"status": True, "message": "", "result": self.__getSumOverSliceRectArea_0(iFREQ, iRA0, iRA1, iDEC0, iDEC1)}
self.__logger.debug("getSumOnSliceRectArea: exiting")
return result
def getAverage(self, step, startZ=None, endZ=None, startY=None, endY=None, startX=None, endX=None, retFITS=False):
def getAverage(self, iFREQ0=None, iFREQ1=None, iDEC0=None, iDEC1=None, iRA0=None, iRA1=None, retFITS=False):
self.__logger.debug("getAverage: entering")
result = self.__getAverage_0( step, startZ, endZ, startY, endY, startX, endX)
result = self.__getAverage_0(iFREQ0, iFREQ1, iDEC0, iDEC1, iRA0, iRA1)
self.__logger.debug("getAverage: exiting")
return {"status": True, "message": "", "result": result.tolist()}
def getOneSliceAsPNG (self, sliceIndex, ittName=__default_transformation_name, lutName=__default_palette_name, vmName=__default_video_mode_name):
def getOneSliceAsPNG (self, iFREQ, ittName=__default_transformation_name, lutName=__default_palette_name, vmName=__default_video_mode_name):
self.__logger.debug("getOneSliceAsPNG: entering.")
relPNGFileDir = ('.').join(self.__relFITSFilePath.split('.')[:-1])
absPNGFileDir = DataBlock.getPNGFilePrefix()+"/"+relPNGFileDir
......@@ -769,19 +756,19 @@ class DataBlock:
shape = data.shape
self.__logger.debug(shape)
if ( sliceIndex >= shape[0] ):
self.__logger.debug("No such slice index '%d' . Max. possible value is '%d'" %(sliceIndex, shape[1]))
if ( iFREQ >= shape[0] ):
self.__logger.debug("No such slice index '%d' . Max. possible value is '%d'" %(iFREQ, shape[1]))
elif ( len(shape) > 4 ):
self.__logger.debug("Can't process data with more than 4 dimensions")
else:
if len(shape) == 2:
sliceData = data
elif len(shape) == 3:
sliceData = data[sliceIndex,:,:]
sliceData = data[iFREQ,:,:]
elif len(shape) == 4:
sliceData = data[0, sliceIndex,:,:]
sliceData = data[0, iFREQ,:,:]
relPNGFilePath = ("%s/%d.%s.%s.%s.png" % (relPNGFileDir, sliceIndex, ittName, lutName, vmName))
relPNGFilePath = ("%s/%d.%s.%s.%s.png" % (relPNGFileDir, iFREQ, ittName, lutName, vmName))
absPNGFilePath = DataBlock.getPNGFilePrefix() + "/" + relPNGFilePath
#if not os.path.exists(absPNGFilePath):
......@@ -821,7 +808,7 @@ class DataBlock:
self.__logger.debug("File '%s' has been created" % absPNGFilePath)
except Exception as e:
self.__logger.debug("Failed to convert slice #%d. Error was '%r'" % (sliceIndex, e))
self.__logger.debug("Failed to convert slice #%d. Error was '%r'" % (iFREQ, e))
self.__logger.debug("Traceback: %s" %traceback.format_exc())
return {"status": False, "message": "Problem while creating the PNG file: '%s'" % e }
else:
......@@ -833,18 +820,18 @@ class DataBlock:
return {"status": True, "message": "", "result": result}
def getSummedSliceRangeAsPNG( self, sliceIndex0, sliceIndex1, ittName=__default_transformation_name, lutName=__default_palette_name, vmName=__default_video_mode_name):
def getSummedSliceRangeAsPNG( self, iFREQ0, iFREQ1, ittName=__default_transformation_name, lutName=__default_palette_name, vmName=__default_video_mode_name):
self.__logger.debug("getSummedSliceRangeAsPNG: entering.")
self.__logger.debug("sliceIndex0=%r, sliceIndex1=%r"%(sliceIndex0, sliceIndex1))
self.__logger.debug("iFREQ0=%r, iFREQ1=%r"%(iFREQ0, iFREQ1))
relPNGFileDir = ('.').join(self.__relFITSFilePath.split('.')[:-1])
absPNGFileDir = DataBlock.getPNGFilePrefix()+"/"+relPNGFileDir
ittName = self.__getForcedTransformationName(ittName)
relPNGFilePath = ("%s/%d-%d.%s.%s.%s.png" % (relPNGFileDir, sliceIndex0, sliceIndex1, ittName, lutName, vmName))
relPNGFilePath = ("%s/%d-%d.%s.%s.%s.png" % (relPNGFileDir, iFREQ0, iFREQ1, ittName, lutName, vmName))
absPNGFilePath = DataBlock.getPNGFilePrefix() + "/" + relPNGFilePath
summedSliceRangeData = self.__getAverage_0(1, sliceIndex0, sliceIndex1)
summedSliceRangeData = self.__getAverage_0(1, iFREQ0, iFREQ1)
status = None
#if not os.path.exists(absPNGFilePath):
......@@ -865,7 +852,7 @@ class DataBlock:
try:
squaredData = self.__squareSliceData(summedSliceRangeData)
data_steps = self.__convertSummedSliceRange2PNG(sliceIndex0, sliceIndex1, squaredData, ittName, lutName, vmName)
data_steps = self.__convertSummedSliceRange2PNG(iFREQ0, iFREQ1, squaredData, ittName, lutName, vmName)
h = self.__header
if "CDELT1" in h and "CDELT2" in h:
x = {"BITPIX": h["BITPIX"],
......
......@@ -136,28 +136,27 @@ class DataManagerImpl :
self.__logger.debug( "getDimensions : exiting");
return result
def getSlice(self, sliceNumb, step, relFITSFilePath):
def getSlice(self, relFITSFilePath, iFREQ, step=1 ):
self.__logger.debug("getSlice : entering")
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getSlice(sliceNumb, step)
result = self.__dataBlocks[relFITSFilePath].getSlice(iFREQ, step)
self.__logger.debug("getSlice : exiting")
return result
def getFreq(self, relFITSFilePath, x=None, y=None, startZ=None, endZ=None):
# y x ou x y
def getFreq(self, relFITSFilePath, iRA=None, iDEC=None, iFREQ0=None, iFREQ1=None):
self.__logger.debug( "getFreq : entering")
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getFreq(x, y, startZ, endZ)
result = self.__dataBlocks[relFITSFilePath].getFreq(iRA, iDEC, iFREQ0, iFREQ1)
self.__logger.debug( "getFreq : exiting")
return result
def getAverageSpectrum(self, relFITSFilePath, startY=None, endY=None, startX=None, endX=None, retFITS=False):
def getAverageSpectrum(self, relFITSFilePath, iDEC0=None, iDEC1=None, iRA0=None, iRA1=None, retFITS=False):
self.__logger.debug("getAverageSpectrum : entering")
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getAverageSpectrum(startY, endY, startX, endX)
result = self.__dataBlocks[relFITSFilePath].getAverageSpectrum(iDEC0, iDEC1, iRA0, iRA1, retFITS)
self.__logger.debug("getAverageSpectrum : exiting")
return result
......@@ -210,37 +209,37 @@ class DataManagerImpl :
self.__logger.debug("getPixelValueAtiFreqiRAiDEC : exiting")
return result
def getSumOverSliceRectArea(self, relFITSFilePath, sliceIndex, RAPix0=None, RAPix1=None, DECPix0=None, DECPix1=None):
def getSumOverSliceRectArea(self, relFITSFilePath, iFREQ, RAPix0=None, RAPix1=None, DECPix0=None, DECPix1=None):
self.__logger.debug("getSumOnSliceRectArea : entering")
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result=self.__dataBlocks[relFITSFilePath].getSumOverSliceRectArea(sliceIndex, RAPix0, RAPix1, DECPix0, DECPix1)
result=self.__dataBlocks[relFITSFilePath].getSumOverSliceRectArea(iFREQ, RAPix0, RAPix1, DECPix0, DECPix1)
self.__logger.debug("getSumOnSliceRectArea : exiting")
return result
def getAverage(self, relFITSFilePath, step, startZ=None, endZ=None, startY=None, endY=None, startX=None, endX=None, retFITS=False):
def getAverage(self, relFITSFilePath, iFREQ0, iFREQ1, iDEC0, iDEC1, iRA0, iRA1, retFITS):
self.__logger.debug("getAverage : entering")
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getAverage(step, startZ, endZ, startY, endY, startX, endX, retFITS)
result = self.__dataBlocks[relFITSFilePath].getAverage(iFREQ0, iFREQ1, iDEC0, iDEC1, iRA0, iRA1, retFITS)
self.__logger.debug("getAverage : exiting")
return result
def getOneSliceAsPNG (self, sliceIndex, relFITSFilePath, **kwargs):
def getOneSliceAsPNG (self, iFREQ, relFITSFilePath, **kwargs):
self.__logger.debug("getOneSliceAsPNG : entering.")
self.__logger.debug("sliceIndex = %r, relFITSFilePath = %r" % (sliceIndex, relFITSFilePath))
self.__logger.debug("iFREQ = %r, relFITSFilePath = %r" % (iFREQ, relFITSFilePath))
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getOneSliceAsPNG(sliceIndex, **kwargs)
result = self.__dataBlocks[relFITSFilePath].getOneSliceAsPNG(iFREQ, **kwargs)
self.__logger.debug("getOneSliceAsPNG : exiting.")
return result
def getSummedSliceRangeAsPNG( self, sliceIndex0, sliceIndex1, relFITSFilePath, **kwargs):
def getSummedSliceRangeAsPNG( self, iFREQ0, iFREQ1, relFITSFilePath, **kwargs):
self.__logger.debug("getSummedSliceRangeAsPNG : entering.")
self.__logger.debug("sliceIndex0=%r, sliceIndex1=%r"%(sliceIndex0, sliceIndex1))
self.__logger.debug("iFREQ0=%r, iFREQ1=%r"%(iFREQ0, iFREQ1))
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result = self.__dataBlocks[relFITSFilePath].getSummedSliceRangeAsPNG(sliceIndex0, sliceIndex1, **kwargs)
result = self.__dataBlocks[relFITSFilePath].getSummedSliceRangeAsPNG(iFREQ0, iFREQ1, **kwargs)
self.__logger.debug("getSummedSliceRangeAsPNG : exiting.")
return result
......
......@@ -243,13 +243,16 @@ def flatten():
@enable_cors
def getPixelValueAtiFreqiRAiDEC():
logger.debug("getPixelValueAtiFreqiRAiDEC - wrapper : entering" )
try:
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
iFreq = getIntValue(request.GET['iFreq'])
iRA = getIntValue(request.GET['iRA'])
iDEC = getIntValue(request.GET['iDEC'])
except Exception as e:
logger.debug(f'{e}')
raise
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
iFreq = getIntValue(request.GET['iFreq'])
iRA = getIntValue(request.GET['iRA'])
iDEC = getIntValue(request.GET['iDEC'])
response.content_type = "application/json; charset=utf-8"
result = json.dumps(dm.getPixelValueAtiFreqiRAiDEC(relFITSFilePath, iFreq, iRA, iDEC))
logger.debug("getPixelValueAtiFreqiRAiDEC - wrapper : exiting" )
return result
......@@ -265,10 +268,14 @@ def getPixelValueAtiFreqiRAiDEC():
def getSlice():
logger.debug("getSlice - wrapper : entering" )
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
sliceNumb = int(request.GET['sliceNumb'])
step = int(request.GET['step'])
result = dm.getSlice(sliceNumb, step, relFITSFilePath)
try:
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
iFREQ = int(request.GET['iFREQ'])
except Exception as e:
logger.debug(f'{e}')
raise
result = dm.getSlice(relFITSFilePath, iFREQ)
response.content_type = "application/json; charset=utf-8"
logger.debug("getSlice - wrapper : exiting" )
......@@ -276,29 +283,33 @@ def getSlice():
"""
Given one pair, x and y, of integer coordinates in the RAxDEC plane and
a frequency range defined by a pair of integers startZ and endZ
returns the values contained in the data cube at [startZ:endZ, x, y]
a frequency range defined by a pair of integers iFREQ0 and iFRE1
returns the values contained in the data cube at [iFREQ0:iFRE1, x, y]
"""
@route( baseUrl+'/getFreq', name='getFreq', method='GET')
@enable_cors
def getFreq():
logger.debug("getFreq - wrapper : entering" )
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
x = getIntValue(request.GET['x'])
y = getIntValue(request.GET['y'])
startZ = getIntValue(request.GET['startZ'])
endZ = getIntValue(request.GET['endZ'])
try:
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
iRA = getIntValue(request.GET['iRA'])
iDEC = getIntValue(request.GET['iDEC'])
iFREQ0 = getIntValue(request.GET['iFREQ0'])
iFREQ1 = getIntValue(request.GET['iFREQ1'])
except Exception as e:
logger.debug(f'{e}')
raise
response.content_type = "application/json; charset=utf-8"
result = json.dumps(dm.getFreq(relFITSFilePath, x, y, startZ, endZ))
logger.debug("getFreq - wrapper : exiting" )
result = json.dumps(dm.getFreq(relFITSFilePath, iRA, iDEC, iFREQ0, iFREQ1))
logger.debug("getFreq - wrapper : exiting")
return result
"""
Given two pairs -- startX,endX and startY,endY -- defining a rectangular area the RAxDEC plane
and a frequency range defined by a pair of integers startZ and endZ
returns the result of numpy.nansum(datacube[startZ:endZ, startY:endY, startX:endX], (1,2))
Given two pairs -- iRA0,iRA1 and iDEC0,iDEC1 -- defining a rectangular area the RAxDEC plane
and a frequency range defined by a pair of integers iFREQ0 and iFRE1
returns the result of numpy.nansum(datacube[iFREQ0:iFRE1, iDEC0:iDEC1, iRA0:iRA1], (1,2))
multiplied by cdelt and divided by convert where
* cdelt == 4 * math.log(2) * abs(CDELT1) * pi180 * abs(CDELT2) * pi180
......@@ -315,63 +326,79 @@ def getAverageSpectrum():
logger.debug("getAverageSpectrum - wrapper : entering" )
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
sessionID = request.GET['sessionID']
startY = getIntValue(request.GET['startY'])
endY = getIntValue(request.GET['endY'])
startX = getIntValue(request.GET['startX'])
endX = getIntValue(request.GET['endX'])
retFITS = getBoolValue(request.GET['retFITS'])
try:
iDEC0 = getIntValue(request.GET['iDEC0'])
iDEC1 = getIntValue(request.GET['iDEC1'])
iRA0 = getIntValue(request.GET['iRA0'])
iRA1 = getIntValue(request.GET['iRA1'])
retFITS = getBoolValue(request.GET['retFITS'])
except Exception as e:
logger.debug(f'{e}')
raise
response.content_type = "application/json; charset=utf-8"
result = json.dumps(dm.getAverageSpectrum(relFITSFilePath, startY, endY, startX, endX, retFITS))
result = json.dumps(dm.getAverageSpectrum(relFITSFilePath, iDEC0, iDEC1, iRA0, iRA1, retFITS))
logger.debug("getAverageSpectrum - wrapper : exiting" )
return result
"""
Given two pairs -- RAPix0,RAPix1 and DECPix0,DECPix1 -- defining a rectangular area the RAxDEC plane
and a frequency defined by an integer sliceIndex
returns the result of numpy.nansum(datacube[sliceIndex, startY:endY, startX:endX], (1,2))
and a frequency defined by an integer iFREQ
returns the result of numpy.nansum(datacube[iFREQ, iDEC0:iDEC1, iRA0:iRA1], (1,2))
multiplied by 4 * log(2) * cdelt1 * pi / 180 / 4.86e-6 * cdelt2 * pi / 180 / 4.86e-6
"""
@route( baseUrl+'/getSumOverSliceRectArea', name='getSumOverSliceRectArea', method='GET')
@enable_cors
def getSumOverSliceRectArea():
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
sessionID = request.GET['sessionID']
DECPix0 = getIntValue(request.GET['DECPix0'])
DECPix1 = getIntValue(request.GET['DECPix1'])
RAPix0 = getIntValue(request.GET['RAPix0'])
RAPix1 = getIntValue(request.GET['RAPix1'])
sliceIndex = getIntValue(request.GET['sliceIndex'])
logger.debug("getSumOverSliceRectArea - wrapper : entering" )
try:
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
DECPix0 = getIntValue(request.GET['DECPix0'])
DECPix1 = getIntValue(request.GET['DECPix1'])
RAPix0 = getIntValue(request.GET['RAPix0'])
RAPix1 = getIntValue(request.GET['RAPix1'])
iFREQ = getIntValue(request.GET['iFREQ'])
except Exception as e:
logger.debug(f'{e}')
raise
response.content_type = "application/json; charset=utf-8"
result = json.dumps(dm.getSumOverSliceRectArea(relFITSFilePath, sliceIndex, RAPix0, RAPix1, DECPix0, DECPix1))
result = json.dumps(dm.getSumOverSliceRectArea(relFITSFilePath, iFREQ, RAPix0, RAPix1, DECPix0, DECPix1))
logger.debug("getSumOverSliceRectArea - wrapper : exiting" )
return result
"""
Given two pairs -- startX,endX and startY,endY -- defining a rectangular area the RAxDEC plane
and a frequency range defined by a pair of integers startZ and endZ
returns the result of numpy.nansum(datacube[startZ:endZ, startY:endY, startX:endX], 0)
Given two pairs -- iRA0,iRA1 and iDEC0,iDEC1 -- defining a rectangular area the RAxDEC plane
and a frequency range defined by a pair of integers iFREQ0 and iFRE1
returns the result of numpy.nansum(datacube[iFREQ0:iFRE1, iDEC0:iDEC1, iRA0:iRA1], 0)
multiplied by 4 * log(2) * cdelt1 * pi / 180 / 4.86e-6 * cdelt2 * pi / 180 / 4.86e-6
"""
@route( baseUrl+'/getAverage', name='getAverage', method='GET')
@enable_cors
def getAverage():
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
sessionID = request.GET['sessionID']
step = getIntValue(request.GET['step'])
startY = getIntValue(request.GET['startY'])
endY = getIntValue(request.GET['endY'])
startX = getIntValue(request.GET['startX'])
endX = getIntValue(request.GET['endX'])
startZ = getIntValue(request.GET['startZ'])
endZ = getIntValue(request.GET['endZ'])
result = dm.getAverage(relFITSFilePath, step, startZ, endZ, startY, endY, startX, endX)
logger.debug("getAverage - wrapper : entering" )
try:
logger.debug(request)
relFITSFilePath = rebuildFilename(request.GET['relFITSFilePath'])
iDEC0 = getIntValue(request.GET['iDEC0'])
iDEC1 = getIntValue(request.GET['iDEC1'])
iRA1 = getIntValue(r