Commit 31f22d7a authored by ba yaye-awa's avatar ba yaye-awa
Browse files

Merge branch 'master' of gitlab.obspm.fr:caillat/yafits

parents 3ec5aff7 78b3f499
......@@ -6,7 +6,6 @@ services:
ports:
- "${YAFITSV_PORT}:3000"
volumes:
- "${YAFITS_FITSDIR}:/home/partemix/dataroot/FITS"
- "${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
- "${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
- "${YAFITS_SAMPDIR}:/home/partemix/dataroot/SAMP"
......@@ -22,16 +21,25 @@ services:
- yafitss
yafitss:
build: ./yafitss
build:
context: ./yafitss
args:
YAFITS_FITSDIR: ${YAFITS_FITSDIR}
YAFITS_FITSDIR2: ${YAFITS_FITSDIR2}
image: yafitss:${USER}
ports:
- "${YAFITSS_PORT}:4251"
volumes:
- "${YAFITS_FITSDIR}:/home/partemix/dataroot/FITS"
- "${YAFITS_FITSDIR}:${YAFITS_FITSDIR}"
- "${YAFITS_FITSDIR2}:${YAFITS_FITSDIR2}"
- "${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
- "${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
- "${YAFITS_LOGDIR}:/home/partemix/log"
environment:
- YAFITS_FITSDIR
- YAFITS_FITSDIR2
- YAFITSS_PORT=${YAFITSS_PORT}
- YAFITSS_MAXIDLE=${YAFITSS_MAXIDLE}
command: python /home/partemix/yafitss/serverWsgi.py --port 4251
......@@ -13,6 +13,13 @@
#
export YAFITS_FITSDIR=/datartemix/ALMA/FITS
#
# A way to extend the disk space allocated to FITS files
# by using symbolic links defined in YAFITS_FITSDIR towards files
# or directories located in YAFITS_FITSDIR2
#
export YAFITS_FITSDIR2=/datartemix2/ALMA/FITS
#
# Where will the temporary PNG files and log files be written.
# Ensure that the directories are writable by anybody or at least
......
......@@ -19,6 +19,7 @@ import png
from PIL import Image, PngImagePlugin
import dask
import dask.array as da
import dask.delayed as dd
import traceback
from datetime import datetime, timedelta
......@@ -186,6 +187,8 @@ class DataBlock:
"idle": None
}
self.__statistics ={}
#===========================================================================
#
# Properties
......@@ -295,6 +298,9 @@ class DataBlock:
#
# Header "normalization"
#
if "BUNIT" in self.__header and self.__header["BUNIT"] == "JY/BEAM":
self.__header["BUNIT"] = "Jy/beam"
if "TELESCOP" not in self.__header:
self.__header["TELESCOP"] = "Unknown"
......@@ -401,21 +407,15 @@ class DataBlock:
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:
if self.__header["NAXIS"] > 2:
x = (dask.array.nansum(self.__data[iFREQ, iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt).compute().tolist()
else :
x = (dask.array.nansum(self.__data[iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt).compute().tolist()
else:
if self.__header["NAXIS"] > 2:
x = np.nansum(self.__data[iFREQ, iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt
else :
x = np.nansum(self.__data[iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt
if self.__header["NAXIS"] > 2:
result = (dask.array.nansum(self.__data[iFREQ, iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt).compute().tolist()
else :
result = (dask.array.nansum(self.__data[iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt).compute().tolist()
self.__logger.debug("__getSumOverSliceRectArea__0: exiting")
return x
return result
def __getAverage_0(self, iFREQ0=None, iFREQ1=None, iDEC0=None, iDEC1=None, iRA0=None, iRA1=None):
self.__logger.debug("__getAverage_0: entering")
......@@ -435,12 +435,6 @@ class DataBlock:
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 = [[]] * (iDEC1 - iDEC0 + 1)
if (self.__header["ORIGIN"]=="GILDAS Consortium"):
self.__logger.debug("Gildas data")
......@@ -463,23 +457,19 @@ class DataBlock:
cdelt = 0.0
self.__logger.debug("slice sum begin")
with_dask = True
if with_dask:
if self.__header["NAXIS"] > 2:
res = (dask.array.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt).compute()
else:
res = (dask.array.nansum(self.__data[iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt).compute()
if self.__header["NAXIS"] > 2:
result = (dask.array.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt).compute()
else:
if self.__header["NAXIS"] > 2:
res = np.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt
else:
res = np.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt
result = self.__data[iDEC0:iDEC1, iRA0:iRA1]*cdelt.compute()
self.__collectStatistics("%d-%d"%(iFREQ0, iFREQ1), result)
self.__logger.debug("slice sum end")
self.__logger.debug("slice sum end")
self.__logger.debug(f"result={result}")
self.__logger.debug("__getAverage_0: exiting")
self.__logger.debug(f"res={res}")
return res
return result
def __getPercentile(self, a, percent):
return np.nanpercentile(a, percent)
......@@ -699,21 +689,56 @@ class DataBlock:
def getDimensions(self):
return {"status": True, "message": "", "result": self.__data.shape}
def __collectStatistics(self, key, data): # data is expected to be a numpy array
self.__logger.debug("__collectStatistics : entering")
if key in self.__statistics:
self.__logger.debug("Statistics are already collected for key %s" % key)
else:
self.__logger.debug("Statistics have to be collected for key %s" % key)
results = []
t = dd(np.nanmin)(data); results.append(t)
t = dd(np.nanmax)(data); results.append(t)
t = dd(np.nanmean)(data); results.append(t)
t = dd(np.nanstd)(data); results.append(t)
t = dd(np.histogram)(data[~np.isnan(data)],bins=100 ); results.append(t)
results = dask.compute(*results)
self.__statistics[key]={}
self.__statistics[key]["min"] = results[0].item()
self.__statistics[key]["max"] = results[1].item()
self.__statistics[key]["mean"] = results[2].item()
self.__statistics[key]["std"] = results[3].item()
self.__statistics[key]["histogram"] = [x.tolist() for x in results[4]]
population = self.__statistics[key]["histogram"][0]
bins = self.__statistics[key]["histogram"][1]
aux = [0 for x in range(len(bins))]
for i in range (1, len(aux)):
aux[i] = aux[i-1]+population[i-1]
normfactor = np.count_nonzero(~np.isnan(data)) #reduce(lambda a,b : a*b, self.__data.shape);
self.__statistics[key]["cumuldist"] = list(map(lambda x: x/normfactor, aux));
self.__logger.debug(self.__statistics[key]);
self.__logger.debug("__collectStatistics : exiting")
def __getSlice(self, iFREQ, step=1):
self.__logger.debug("__getSlice: entering")
x = None
result = None
numDimensions = len(self.__data.shape)
if numDimensions == 2:
x = self.__data[0:self.__data.shape[0]:step, 0:self.__data.shape[1]:step]
result = self.__data[0:self.__data.shape[0]:step, 0:self.__data.shape[1]:step]
elif numDimensions == 3:
if iFREQ == None:
iFREQ = self.__data.shape[0] / 2
x = self.__data[iFREQ, 0:self.__data.shape[1]:step, 0:self.__data.shape[2]:step]
self.__logger.debug("__getSlice: exiting")
result = self.__data[iFREQ, 0:self.__data.shape[1]:step, 0:self.__data.shape[2]:step]
return x
#
# Collect some statistics if not already done
#
self.__collectStatistics("%d"%iFREQ, result.compute())
self.__logger.debug("__getSlice: exiting")
return result # A DASK array
def getSlice(self, iFREQ, step=1):
self.__logger.debug("getSlice: entering")
......@@ -737,7 +762,9 @@ class DataBlock:
self.__logger.debug("Apres isnan")
result["status"]=True
result["message"]=""
result["result"]=x.tolist()
result["result"]={}
result["result"]["slice"]=x.tolist()
result["result"]["statistics"]=self.__statistics["%d"%iFREQ]
except Exception as e:
result["message"]=f"An exception occurred with message {e}"
result["status"]= False
......@@ -835,7 +862,7 @@ class DataBlock:
status = None
sliceData = None
data = self.__data #self.__HDUList[0].data
data = self.__data
shape = data.shape
self.__logger.debug(shape)
......@@ -844,12 +871,7 @@ class DataBlock:
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[iFREQ,:,:]
elif len(shape) == 4:
sliceData = data[0, iFREQ,:,:]
sliceData = self.__getSlice(iFREQ)
relPNGFilePath = ("%s/%d.%s.%s.%s.png" % (relPNGFileDir, iFREQ, ittName, lutName, vmName))
absPNGFilePath = DataBlock.getPNGFilePrefix() + "/" + relPNGFilePath
......@@ -898,7 +920,7 @@ class DataBlock:
status = True
self.__logger.debug("Using cached file '%s'" % absPNGFilePath)
result = {"data_steps": data_steps, "path_to_png": relPNGFilePath}
result = {"data_steps": data_steps, "path_to_png": relPNGFilePath, "statistics": self.__statistics["%d"%iFREQ]}
self.__logger.debug("getOneSliceAsPNG: exiting.")
return {"status": True, "message": "", "result": result}
......@@ -959,7 +981,7 @@ class DataBlock:
status = True
self.__logger.debug("Using cached file '%s'" % absPNGFilePath)
result = {"data_steps": data_steps, "path_to_png": relPNGFilePath}
result = {"data_steps": data_steps, "path_to_png": relPNGFilePath, "statistics": self.__statistics["%d-%d"%(iFREQ0, iFREQ1)]}
self.__logger.debug("getSummedSliceRangeAsPNG: exiting.")
return {"status": True, "message": "", "result": result}
......@@ -1138,9 +1160,9 @@ class DataBlock:
iRA1 = iRA1 if iRA1 else (self.__data.shape[2] if numDims > 2 else self.__data.shape[1])
# Get the data to be contoured
slice = self.__getSlice(iFREQ)[iDEC0:iDEC1, iRA0:iRA1]
self.__logger.debug("slice shape %r", slice.shape)
#self.__logger.debug("%r,%r" % (da.min(slice[!da.isnan(slice)]).compute(), da.max(slice[!da.isnan(slice)]).compute()))
slice = self.__getSlice(iFREQ).compute()
shape = slice.shape
self.__logger.debug("slice shape %r", shape)
# Determine the contours levels.
levels = None
......@@ -1150,31 +1172,32 @@ class DataBlock:
if key == 'levels':
levels = value
elif key == 'quantiles':
levels = [np.quantile(slice[~da.isnan(slice)].compute(), quantile) for quantile in value]
levels = [np.quantile(slice[~np.isnan(slice)], quantile) for quantile in value]
elif key == 'numberOfBins':
levels = np.histogram_bin_edges(slice[~da.isnan(slice)].compute(), value)
levels = np.histogram_bin_edges(slice[~np.isnan(slice)], value)
elif key == 'histBinsMethod':
levels = np.histogram_bin_edges(slice[~da.isnan(slice)].compute(), value)
levels = np.histogram_bin_edges(slice[~np.isnan(slice)], value)
levels = levels [-10:]
self.__logger.debug("levels = %r" % (levels))
# Produce the contours.
features = []
fig, ax = pp.subplots()
#CS = ax.contour(np.arange(slice.shape[1]), np.arange(slice.shape[0]), slice, levels)
CS = ax.contour(slice, levels)
for level, set in zip(CS.levels, CS.allsegs):
for c in set :
for level in levels:
slice_bw = np.zeros(shape, dtype=np.uint8)
slice_bw[slice >= level] = 127
contours, _ = cv2.findContours(slice_bw, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours :
pts = [x[0] for x in contour.tolist()]
#pts = [[x[0], shape[0] - x[1] -1] for x in pts]
feature = {"type":"LineString", \
"coordinates": [[round(x[0]), round(x[1])] for x in c.tolist()],\
"properties": {"level" : level}}
"coordinates": pts,\
"properties": {"level" : {"value": level, "unit" : self.__header["BUNIT"]}}}
features.append(feature)
contours_geojson = { "type": "FeatureCollection", "features" : features }
result = {"status" : True, "message" : "", "result": contours_geojson}
self.__logger.debug(contours_geojson)
self.__logger.debug("getContours: exiting")
return result
......@@ -1182,29 +1205,74 @@ class DataBlock:
self.__logger.debug("measureContour : entering")
slice = self.__getSlice(iFREQ).compute()
shape = slice.shape
theMask = np.empty(shape, dtype=bool)
bdr = cv2.boundingRect(contour)
numpix = 0
x,y,w,h = cv2.boundingRect(contour)
x,y,w,h = bdr
accum = []
for j in np.arange(y, y+h):
for i in np.arange(x, x+w):
theMask[j][i] = cv2.pointPolygonTest(contour, (i, j), False) != -1 and slice[j][i] >= level
if theMask[j][i] :
numpix += 1
if cv2.pointPolygonTest(contour, (i, j), False) != -1 and slice[j][i] >= level:
accum.append(slice[j,i])
accum = np.asarray(accum)
result = {}
result["sum"] = "%11.4g" % (np.nansum(slice[theMask]).item() / self.__convert * self.__cdelt);
result["min"] = "%11.4g" % (np.nanmin(slice[theMask]).item())
result["max"] = "%11.4g" % (np.nanmax(slice[theMask]).item())
result["mean"] = "%11.4g" % (np.nanmean(slice[theMask]).item())
result["var"] = "%11.4g" % (np.nanvar(slice[theMask]).item())
result["numpix"] = numpix
result["percent"] = "%9.2g" % (numpix / (shape[0]*shape[1]) * 100)
result["boundingRect"] = cv2.boundingRect(contour)
bunit = self.__header["BUNIT"]
if bunit == "Jy/beam" :
sumunit = "Jy"
bunit = "Jy/beam"
else:
sumunit = bunit
result["sum"] = {"value": np.sum(accum).item() / self.__convert * self.__cdelt , "unit" : sumunit}
result["min"] = {"value": np.min(accum).item() , "unit": bunit}
result["max"] = {"value": np.max(accum).item() , "unit": bunit}
result["mean"] = {"value": np.mean(accum).item() , "unit": bunit}
result["stdev"] = {"value": np.std(accum).item() , "unit": bunit}
result["numpix"] = {"value": accum.shape[0], "unit" : "pixels"}
result["percentage of total number of pixels"] = {"value": accum.shape[0] / (shape[0]*shape[1]) * 100, "unit": "%"}
result["boundingRect"] = {"value" :bdr, "unit" :"pixels"}
result = {"status":True, "message":"", "result":result}
self.__logger.debug("measureContour : exiting")
return result
def measureBox(self, iFREQ, iRA0=None, iRA1=None, iDEC0=None, iDEC1=None):
self.__logger.debug("measureBox: entering")
numDims = len(self.__data.shape)
iDEC0 = iDEC0 if iDEC0 else 0
iDEC1 = iDEC1 if iDEC1 else (self.__data.shape[1] if numDims > 2 else self.__data.shape[0])
iRA0 = iRA0 if iRA0 else 0
iRA1 = iRA1 if iRA1 else (self.__data.shape[2] if numDims > 2 else self.__data.shape[1])
box = self.__getSlice(iFREQ).compute()[iDEC0:iDEC1, iRA0:iRA1]
shape = self.__data.shape
result = {}
bunit = self.__header["BUNIT"]
if bunit == "Jy/beam" :
sumunit = "Jy"
bunit = "Jy/beam"
else:
sumunit = bunit
self.__logger.debug(iRA0);
self.__logger.debug(iRA1);
self.__logger.debug(iDEC0);
self.__logger.debug(iDEC1);
self.__logger.debug(shape)
self.__logger.debug(type(box))
result["sum"] = {"value": np.nansum(box).item() / self.__convert * self.__cdelt , "unit" : sumunit}
result["min"] = {"value": np.nanmin(box).item() , "unit": bunit}
result["max"] = {"value": np.nanmax(box).item() , "unit": bunit}
result["mean"] = {"value": np.nanmean(box).item() , "unit": bunit}
result["stdev"] = {"value": np.nanstd(box).item() , "unit": bunit}
result["numpix"] = {"value": np.count_nonzero(~np.isnan(box)), "unit" : "pixels (!=Nan)"}
result["percentage of total number of pixels"] = {"value": (box.shape[0]*box.shape[1]) / (self.__header["NAXIS1"]*self.__header["NAXIS2"]) * 100, "unit": "%"}
result["boundingRect"] = {"value":[iRA0, iDEC0, iRA1-iRA0, iDEC1-iDEC0], "unit":"pixels"}
result = {"status":True, "message":"", "result":result}
self.__logger.debug("measureBox : exiting")
return result
#
# End of DataBlock class definition.
#
......@@ -70,9 +70,20 @@ RUN echo "PATH=$PATH"
#------------------------------------------------------------#
# Create some directories expected by the application.
ARG YAFITS_FITSDIR
ARG YAFITS_FITSDIR2
ENV YAFITS_FITSDIR=$YAFITS_FITSDIR
ENV YAFITS_FITSDIR2=$YAFITS_FITSDIR2
# The root directory of the FITS files location (readonly). It'll have to be bound to an host directory.
RUN mkdir -p /home/partemix/dataroot/FITS
RUN printenv
RUN sudo mkdir -p ${YAFITS_FITSDIR}
RUN sudo chown partemix:partemix ${YAFITS_FITSDIR}
# The first extension to the root directory of FITS files location (readonly). It'll have to be bound to an host directory.
RUN sudo mkdir -p ${YAFITS_FITSDIR2}
RUN sudo chown partemix:partemix ${YAFITS_FITSDIR2}
# The root directory of the PNG files (read/write). It'll have to be bound to an host directory.
RUN mkdir -p /home/partemix/dataroot/PNG
......@@ -114,3 +125,4 @@ RUN ls -l /home/partemix/anaconda3/pkgs/matplotlib-3.0.3-py37h5429711_0/lib/
# ./yafitss/serverWsgi.michel will be listening at 4251
EXPOSE 4251
......@@ -15,8 +15,12 @@ from datetime import datetime
from DataBlock import DataBlock
DataRoot = "dataroot"
FITSFilePrefix = DataRoot + '/FITS/'
FITSFilePrefix = os.getenv("YAFITS_FITSDIR")
# Ensure that FITSFilePrefix ends with a '/'
if not FITSFilePrefix.endswith("/"):
FITSFilePrefix += "/"
DataRoot = "/home/partemix/dataroot"
PNGFilePrefix = DataRoot + '/PNG/'
OBJFilePrefix = DataRoot + '/OBJ/'
ApiDocPrefix = DataRoot + '/apidoc/'
......@@ -62,19 +66,29 @@ class DataManagerImpl :
try :
absFITSFilePrefix = FITSFilePrefix + relKey
entries = (os.listdir(absFITSFilePrefix))
self.__logger.debug("type of entries %s" % (type(entries)))
self.__logger.debug("%r" % entries)
sortedEntries = entries.sort()
children = []
for entry in entries:
p = absFITSFilePrefix + '/' + entry
if entry.startswith(".") or (not os.path.isdir(p) and not p.endswith(".fits")) :
condition = (os.path.isfile(p) and p.endswith(".fits"))
if not condition :
self.__logger.debug("%s link %r" % (p, os.path.islink(p)))
if os.path.islink(p):
target = os.path.realpath(p)
self.__logger.debug("%s is dir %r" %(target, os.path.isdir(target)))
condition = os.path.islink(p) # and os.path.isdir(target)
else :
condition = (os.path.isdir(p))
if not condition :
continue
elif entry in ["log", "NOFITS", "IGNORE"]:
continue
else:
d = dict()
d["key"] = relKey + '/' + entry
d["folder"] = os.path.isdir(p)
d["folder"] = not os.path.isfile(p)
d["lazy"] = d["folder"]
if entry.endswith(".fits") :
size = DataBlock.convert_size(os.path.getsize(p))
......@@ -86,6 +100,7 @@ class DataManagerImpl :
except Exception as e :
result = {"status": False, "message": "Problem while looking for entries under '%s'. Error message was '%s'" % ( relKey, e)}
self.__logger.debug("%r" % result)
self.__logger.debug("%r" % result)
self.__logger.debug("__getEntries_0: exiting")
return result
......@@ -219,11 +234,11 @@ class DataManagerImpl :
self.__logger.debug("getPixelValueAtiFreqiRAiDEC : exiting")
return result
def getSumOverSliceRectArea(self, relFITSFilePath, iFREQ, RAPix0=None, RAPix1=None, DECPix0=None, DECPix1=None):
def getSumOverSliceRectArea(self, relFITSFilePath, iFREQ, iRA0=None, iRA1=None, iDEC0=None, iDEC1=None):
self.__logger.debug("getSumOnSliceRectArea : entering")
result = self.__checkPresence(relFITSFilePath)
if result["status"]:
result=self.__dataBlocks[relFITSFilePath].getSumOverSliceRectArea(iFREQ, RAPix0, RAPix1, DECPix0, DECPix1)
result=self.__dataBlocks[relFITSFilePath].getSumOverSliceRectArea(iFREQ, iRA0, iRA1, iDEC0, iDEC1)
self.__logger.debug("getSumOnSliceRectArea : exiting")
return result
......@@ -268,6 +283,14 @@ class DataManagerImpl :
self.__logger.debug("measureContour - dispatcher : exiting")
return result
def measureBox(self, relFITSFilePath, iFREQ, iRA0, iRA1, iDEC0, iDEC1):
self.__logger.debug("measureBox - dispatcher : entering")
result = self.__checkPresence(relFITSFilePath)
if result["status"] :
result = self.__dataBlocks[relFITSFilePath].measureBox(iFREQ, iRA0, iRA1, iDEC0, iDEC1)
self.__logger.debug("measureBox - dispatcher : exiting")
return result
#
# create fits file containing a spectrum at iRA, iDEC
......
......@@ -560,12 +560,12 @@ def getSumOverSliceRectArea():
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'])
iDEC0 = getIntValue(request.GET['iDEC0'])
iDEC1 = getIntValue(request.GET['iDEC1'])
iRA0 = getIntValue(request.GET['iRA0'])
iRA1 = getIntValue(request.GET['iRA1'])
iFREQ = getIntValue(request.GET['iFREQ'])
result = json.dumps(dm.getSumOverSliceRectArea(relFITSFilePath, iFREQ, RAPix0, RAPix1, DECPix0, DECPix1))
result = json.dumps(dm.getSumOverSliceRectArea(relFITSFilePath, iFREQ, iRA0, iRA1, iDEC0, iDEC1))
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
message = "%s ! %s" % (type(e), "".join(traceback.format_list(traceback.extract_tb(exc_traceback))))
......@@ -881,6 +881,29 @@ def measureContour():
logger.debug("measureContour - wrapper : exiting")
return json.dumps(result)
@route( baseUrl+'/measureBox', name='measureBox', method='POST')
@enable_cors
def measureBox():
logger.debug("measureContour - wrapper : entering")
try:
body = byteify(json.loads(request.body.read()))
relFITSFilePath = rebuildFilename(body['relFITSFilePath'])
iFREQ = getIntValue(body['iFREQ'])
iRA0 = getIntValue(body['iRA0']) if 'iRA0' in body else None
iRA1 = getIntValue(body['iRA1']) if 'iRA1' in body else None
iDEC0 = getIntValue(body['iDEC0']) if 'iDEC0' in body else None
iDEC1 = getIntValue(body['iDEC1']) if 'iDEC1' in body else None
result = dm.measureBox(relFITSFilePath, iFREQ, iDEC0, iDEC1, iRA0, iRA1)
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
message = "%s ! %s" % (type(e), "".join(traceback.format_list(traceback.extract_tb(exc_traceback))))
logger.debug(message)
result = {"status": False, "message": message}
response.content_type = "application/json; charset=utf-8"
logger.debug("measureContour - wrapper : exiting")
return json.dumps(result)
"""
Given the values of a spectrum 'ydata' passed with the corresponding frequency values 'xdata'
......
......@@ -80,3 +80,4 @@ COPY --chown=partemix:partemix . /home/partemix/yafitsv
RUN ls -l /home/partemix/yafitsv
EXPOSE 3000
......@@ -4,6 +4,7 @@ var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var fs = require('fs');
var index = require('./routes/index');
var users = require('./routes/users');
......@@ -12,9 +13,9 @@ var connectArtemix = require('./routes/connectArtemix')
var fitsBrowser = require('./routes/fitsBrowser');
var monitor = require('./routes/monitor');
var purge = require('./routes/purge');
const dir