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: ...@@ -6,7 +6,6 @@ services:
ports: ports:
- "${YAFITSV_PORT}:3000" - "${YAFITSV_PORT}:3000"
volumes: volumes:
- "${YAFITS_FITSDIR}:/home/partemix/dataroot/FITS"
- "${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG" - "${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
- "${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ" - "${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
- "${YAFITS_SAMPDIR}:/home/partemix/dataroot/SAMP" - "${YAFITS_SAMPDIR}:/home/partemix/dataroot/SAMP"
...@@ -22,16 +21,25 @@ services: ...@@ -22,16 +21,25 @@ services:
- yafitss - yafitss
yafitss: yafitss:
build: ./yafitss build:
context: ./yafitss
args:
YAFITS_FITSDIR: ${YAFITS_FITSDIR}
YAFITS_FITSDIR2: ${YAFITS_FITSDIR2}
image: yafitss:${USER} image: yafitss:${USER}
ports: ports:
- "${YAFITSS_PORT}:4251" - "${YAFITSS_PORT}:4251"
volumes: volumes:
- "${YAFITS_FITSDIR}:/home/partemix/dataroot/FITS" - "${YAFITS_FITSDIR}:${YAFITS_FITSDIR}"
- "${YAFITS_FITSDIR2}:${YAFITS_FITSDIR2}"
- "${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG" - "${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
- "${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ" - "${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
- "${YAFITS_LOGDIR}:/home/partemix/log" - "${YAFITS_LOGDIR}:/home/partemix/log"
environment: environment:
- YAFITS_FITSDIR
- YAFITS_FITSDIR2
- YAFITSS_PORT=${YAFITSS_PORT} - YAFITSS_PORT=${YAFITSS_PORT}
- YAFITSS_MAXIDLE=${YAFITSS_MAXIDLE} - YAFITSS_MAXIDLE=${YAFITSS_MAXIDLE}
command: python /home/partemix/yafitss/serverWsgi.py --port 4251 command: python /home/partemix/yafitss/serverWsgi.py --port 4251
...@@ -13,6 +13,13 @@ ...@@ -13,6 +13,13 @@
# #
export YAFITS_FITSDIR=/datartemix/ALMA/FITS 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. # Where will the temporary PNG files and log files be written.
# Ensure that the directories are writable by anybody or at least # Ensure that the directories are writable by anybody or at least
......
...@@ -19,6 +19,7 @@ import png ...@@ -19,6 +19,7 @@ import png
from PIL import Image, PngImagePlugin from PIL import Image, PngImagePlugin
import dask import dask
import dask.array as da import dask.array as da
import dask.delayed as dd
import traceback import traceback
from datetime import datetime, timedelta from datetime import datetime, timedelta
...@@ -186,6 +187,8 @@ class DataBlock: ...@@ -186,6 +187,8 @@ class DataBlock:
"idle": None "idle": None
} }
self.__statistics ={}
#=========================================================================== #===========================================================================
# #
# Properties # Properties
...@@ -295,6 +298,9 @@ class DataBlock: ...@@ -295,6 +298,9 @@ class DataBlock:
# #
# Header "normalization" # Header "normalization"
# #
if "BUNIT" in self.__header and self.__header["BUNIT"] == "JY/BEAM":
self.__header["BUNIT"] = "Jy/beam"
if "TELESCOP" not in self.__header: if "TELESCOP" not in self.__header:
self.__header["TELESCOP"] = "Unknown" self.__header["TELESCOP"] = "Unknown"
...@@ -401,21 +407,15 @@ class DataBlock: ...@@ -401,21 +407,15 @@ class DataBlock:
def __getSumOverSliceRectArea_0(self, iFREQ, iRA0=None, iRA1=None, iDEC0=None, iDEC1=None): def __getSumOverSliceRectArea_0(self, iFREQ, iRA0=None, iRA1=None, iDEC0=None, iDEC1=None):
self.__logger.debug("__getSumOverSliceRectArea_0: entering") 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:
if self.__header["NAXIS"] > 2: result = (dask.array.nansum(self.__data[iFREQ, iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt).compute().tolist()
x = np.nansum(self.__data[iFREQ, iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt else :
else : result = (dask.array.nansum(self.__data[iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt).compute().tolist()
x = np.nansum(self.__data[iDEC0:iDEC1, iRA0:iRA1]) / self.__convert * self.__cdelt
self.__logger.debug("__getSumOverSliceRectArea__0: exiting") 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): 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("__getAverage_0: entering")
...@@ -435,12 +435,6 @@ class DataBlock: ...@@ -435,12 +435,6 @@ class DataBlock:
iFREQ1 = self.__data.shape[0] iFREQ1 = self.__data.shape[0]
self.__logger.debug(f"{iFREQ0}, {iFREQ1}, {iDEC0}, {iDEC1}, {iRA0}, {iRA1}") 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"): if (self.__header["ORIGIN"]=="GILDAS Consortium"):
self.__logger.debug("Gildas data") self.__logger.debug("Gildas data")
...@@ -463,23 +457,19 @@ class DataBlock: ...@@ -463,23 +457,19 @@ class DataBlock:
cdelt = 0.0 cdelt = 0.0
self.__logger.debug("slice sum begin") self.__logger.debug("slice sum begin")
with_dask = True
if with_dask: if self.__header["NAXIS"] > 2:
if self.__header["NAXIS"] > 2: result = (dask.array.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt).compute()
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()
else: else:
if self.__header["NAXIS"] > 2: result = self.__data[iDEC0:iDEC1, iRA0:iRA1]*cdelt.compute()
res = np.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt
else: self.__collectStatistics("%d-%d"%(iFREQ0, iFREQ1), result)
res = np.nansum(self.__data[iFREQ0:iFREQ1, iDEC0:iDEC1, iRA0:iRA1], 0)*cdelt
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("__getAverage_0: exiting")
self.__logger.debug(f"res={res}") return result
return res
def __getPercentile(self, a, percent): def __getPercentile(self, a, percent):
return np.nanpercentile(a, percent) return np.nanpercentile(a, percent)
...@@ -699,21 +689,56 @@ class DataBlock: ...@@ -699,21 +689,56 @@ class DataBlock:
def getDimensions(self): def getDimensions(self):
return {"status": True, "message": "", "result": self.__data.shape} 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): def __getSlice(self, iFREQ, step=1):
self.__logger.debug("__getSlice: entering") self.__logger.debug("__getSlice: entering")
x = None result = None
numDimensions = len(self.__data.shape) numDimensions = len(self.__data.shape)
if numDimensions == 2: 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: elif numDimensions == 3:
if iFREQ == None: if iFREQ == None:
iFREQ = self.__data.shape[0] / 2 iFREQ = self.__data.shape[0] / 2
x = self.__data[iFREQ, 0:self.__data.shape[1]:step, 0:self.__data.shape[2]:step] result = self.__data[iFREQ, 0:self.__data.shape[1]:step, 0:self.__data.shape[2]:step]
self.__logger.debug("__getSlice: exiting")
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): def getSlice(self, iFREQ, step=1):
self.__logger.debug("getSlice: entering") self.__logger.debug("getSlice: entering")
...@@ -737,7 +762,9 @@ class DataBlock: ...@@ -737,7 +762,9 @@ class DataBlock:
self.__logger.debug("Apres isnan") self.__logger.debug("Apres isnan")
result["status"]=True result["status"]=True
result["message"]="" result["message"]=""
result["result"]=x.tolist() result["result"]={}
result["result"]["slice"]=x.tolist()
result["result"]["statistics"]=self.__statistics["%d"%iFREQ]
except Exception as e: except Exception as e:
result["message"]=f"An exception occurred with message {e}" result["message"]=f"An exception occurred with message {e}"
result["status"]= False result["status"]= False
...@@ -835,7 +862,7 @@ class DataBlock: ...@@ -835,7 +862,7 @@ class DataBlock:
status = None status = None
sliceData = None sliceData = None
data = self.__data #self.__HDUList[0].data data = self.__data
shape = data.shape shape = data.shape
self.__logger.debug(shape) self.__logger.debug(shape)
...@@ -844,12 +871,7 @@ class DataBlock: ...@@ -844,12 +871,7 @@ class DataBlock:
elif ( len(shape) > 4 ): elif ( len(shape) > 4 ):
self.__logger.debug("Can't process data with more than 4 dimensions") self.__logger.debug("Can't process data with more than 4 dimensions")
else: else:
if len(shape) == 2: sliceData = self.__getSlice(iFREQ)
sliceData = data
elif len(shape) == 3:
sliceData = data[iFREQ,:,:]
elif len(shape) == 4:
sliceData = data[0, iFREQ,:,:]
relPNGFilePath = ("%s/%d.%s.%s.%s.png" % (relPNGFileDir, iFREQ, ittName, lutName, vmName)) relPNGFilePath = ("%s/%d.%s.%s.%s.png" % (relPNGFileDir, iFREQ, ittName, lutName, vmName))
absPNGFilePath = DataBlock.getPNGFilePrefix() + "/" + relPNGFilePath absPNGFilePath = DataBlock.getPNGFilePrefix() + "/" + relPNGFilePath
...@@ -898,7 +920,7 @@ class DataBlock: ...@@ -898,7 +920,7 @@ class DataBlock:
status = True status = True
self.__logger.debug("Using cached file '%s'" % absPNGFilePath) 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.") self.__logger.debug("getOneSliceAsPNG: exiting.")
return {"status": True, "message": "", "result": result} return {"status": True, "message": "", "result": result}
...@@ -959,7 +981,7 @@ class DataBlock: ...@@ -959,7 +981,7 @@ class DataBlock:
status = True status = True
self.__logger.debug("Using cached file '%s'" % absPNGFilePath) 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.") self.__logger.debug("getSummedSliceRangeAsPNG: exiting.")
return {"status": True, "message": "", "result": result} return {"status": True, "message": "", "result": result}
...@@ -1138,9 +1160,9 @@ class DataBlock: ...@@ -1138,9 +1160,9 @@ class DataBlock:
iRA1 = iRA1 if iRA1 else (self.__data.shape[2] if numDims > 2 else self.__data.shape[1]) iRA1 = iRA1 if iRA1 else (self.__data.shape[2] if numDims > 2 else self.__data.shape[1])
# Get the data to be contoured # Get the data to be contoured
slice = self.__getSlice(iFREQ)[iDEC0:iDEC1, iRA0:iRA1] slice = self.__getSlice(iFREQ).compute()
self.__logger.debug("slice shape %r", slice.shape) shape = slice.shape
#self.__logger.debug("%r,%r" % (da.min(slice[!da.isnan(slice)]).compute(), da.max(slice[!da.isnan(slice)]).compute())) self.__logger.debug("slice shape %r", shape)
# Determine the contours levels. # Determine the contours levels.
levels = None levels = None
...@@ -1150,31 +1172,32 @@ class DataBlock: ...@@ -1150,31 +1172,32 @@ class DataBlock:
if key == 'levels': if key == 'levels':
levels = value levels = value
elif key == 'quantiles': 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': 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': 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:] levels = levels [-10:]
self.__logger.debug("levels = %r" % (levels)) self.__logger.debug("levels = %r" % (levels))
# Produce the contours. # Produce the contours.
features = [] 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 in levels:
for level, set in zip(CS.levels, CS.allsegs): slice_bw = np.zeros(shape, dtype=np.uint8)
for c in set : 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", \ feature = {"type":"LineString", \
"coordinates": [[round(x[0]), round(x[1])] for x in c.tolist()],\ "coordinates": pts,\
"properties": {"level" : level}} "properties": {"level" : {"value": level, "unit" : self.__header["BUNIT"]}}}
features.append(feature) features.append(feature)
contours_geojson = { "type": "FeatureCollection", "features" : features } contours_geojson = { "type": "FeatureCollection", "features" : features }
result = {"status" : True, "message" : "", "result": contours_geojson} result = {"status" : True, "message" : "", "result": contours_geojson}
self.__logger.debug(contours_geojson)
self.__logger.debug("getContours: exiting") self.__logger.debug("getContours: exiting")
return result return result
...@@ -1182,29 +1205,74 @@ class DataBlock: ...@@ -1182,29 +1205,74 @@ class DataBlock:
self.__logger.debug("measureContour : entering") self.__logger.debug("measureContour : entering")
slice = self.__getSlice(iFREQ).compute() slice = self.__getSlice(iFREQ).compute()
shape = slice.shape shape = slice.shape
theMask = np.empty(shape, dtype=bool) bdr = cv2.boundingRect(contour)
numpix = 0 numpix = 0
x,y,w,h = cv2.boundingRect(contour) x,y,w,h = bdr
accum = []
for j in np.arange(y, y+h): for j in np.arange(y, y+h):
for i in np.arange(x, x+w): for i in np.arange(x, x+w):
theMask[j][i] = cv2.pointPolygonTest(contour, (i, j), False) != -1 and slice[j][i] >= level if cv2.pointPolygonTest(contour, (i, j), False) != -1 and slice[j][i] >= level:
if theMask[j][i] : accum.append(slice[j,i])
numpix += 1
accum = np.asarray(accum)
result = {} result = {}
result["sum"] = "%11.4g" % (np.nansum(slice[theMask]).item() / self.__convert * self.__cdelt); bunit = self.__header["BUNIT"]
result["min"] = "%11.4g" % (np.nanmin(slice[theMask]).item()) if bunit == "Jy/beam" :
result["max"] = "%11.4g" % (np.nanmax(slice[theMask]).item()) sumunit = "Jy"
result["mean"] = "%11.4g" % (np.nanmean(slice[theMask]).item()) bunit = "Jy/beam"
result["var"] = "%11.4g" % (np.nanvar(slice[theMask]).item()) else:
result["numpix"] = numpix sumunit = bunit
result["percent"] = "%9.2g" % (numpix / (shape[0]*shape[1]) * 100) result["sum"] = {"value": np.sum(accum).item() / self.__convert * self.__cdelt , "unit" : sumunit}
result["boundingRect"] = cv2.boundingRect(contour) 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} result = {"status":True, "message":"", "result":result}
self.__logger.debug("measureContour : exiting") self.__logger.debug("measureContour : exiting")
return result 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. # End of DataBlock class definition.
# #
...@@ -70,9 +70,20 @@ RUN echo "PATH=$PATH" ...@@ -70,9 +70,20 @@ RUN echo "PATH=$PATH"
#------------------------------------------------------------# #------------------------------------------------------------#
# Create some directories expected by the application. # 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. # 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. # 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 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/ ...@@ -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 # ./yafitss/serverWsgi.michel will be listening at 4251
EXPOSE 4251 EXPOSE 4251
...@@ -15,8 +15,12 @@ from datetime import datetime ...@@ -15,8 +15,12 @@ from datetime import datetime
from DataBlock import DataBlock from DataBlock import DataBlock
DataRoot = "dataroot" FITSFilePrefix = os.getenv("YAFITS_FITSDIR")
FITSFilePrefix = DataRoot + '/FITS/' # Ensure that FITSFilePrefix ends with a '/'
if not FITSFilePrefix.endswith("/"):
FITSFilePrefix += "/"
DataRoot = "/home/partemix/dataroot"
PNGFilePrefix = DataRoot + '/PNG/' PNGFilePrefix = DataRoot + '/PNG/'
OBJFilePrefix = DataRoot + '/OBJ/' OBJFilePrefix = DataRoot + '/OBJ/'
ApiDocPrefix = DataRoot + '/apidoc/' ApiDocPrefix = DataRoot + '/apidoc/'
...@@ -62,19 +66,29 @@ class DataManagerImpl : ...@@ -62,19 +66,29 @@ class DataManagerImpl :
try : try :
absFITSFilePrefix = FITSFilePrefix + relKey absFITSFilePrefix = FITSFilePrefix + relKey
entries = (os.listdir(absFITSFilePrefix)) entries = (os.listdir(absFITSFilePrefix))
self.__logger.debug("type of entries %s" % (type(entries))) self.__logger.debug("%r" % entries)
sortedEntries = entries.sort() sortedEntrie