Commit 1fd77772 authored by ba yaye-awa's avatar ba yaye-awa
Browse files

add new parameters to get best 3D images in threeJS

parent de903483
version: '3'
services:
yafitsv:
build: ./yafitsv
image: yafitsv:${USER}
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"
- "${YAFITS_LOGDIR}:/home/partemix/log"
environment:
- YAFITSS_HOST=yafitss
- YAFITSS_PORT=4251
- YAFITSV_HOST=${YAFITSV_HOST}
- YAFITSV_PORT=${YAFITSV_PORT}
- PORT=3000
command: /home/partemix/yafitsv/bin/www > /home/partemix/log/yafitsv.log 2> /home/partemix/log/yafitsv_err.log
links:
- yafitss
yafitss:
build: ./yafitss
image: yafitss:${USER}
ports:
- "${YAFITSS_PORT}:4251"
volumes:
- "${YAFITS_FITSDIR}:/home/partemix/dataroot/FITS"
- "${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
- "${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
- "${YAFITS_LOGDIR}:/home/partemix/log"
environment:
- YAFITSS_PORT:${YAFITSS_PORT}
command: python ./yafitss/serverWsgi.michel.py --port 4251
samphubbis:
#image: openjdk:7
#working_dir: "/home/partemix"
build: ./samphubbis
image: samphubbis:${USER}
ports:
- "${SAMP_HUB_PORT}:21012"
volumes:
#- "/home/awa/.samp:/home/partemix/.samp:ro"
- "/home/awa/Documents/Developpement/javascript/artemix/nodejs_docker/yafits/samphubbis:/home/partemix"
- "/tmp/.X11-unix:/tmp/.X11-unix"
environment:
- DISPLAY=$DISPLAY
- SAMP_HUB_PORT:${SAMP_HUB_PORT}
#command: bash -c "cd /home/partemix && java -jar jsamp-1.3-3.jar hub"
command: bash -c "cd /home/partemix && python runHub.py"
network_mode: host
......@@ -985,8 +985,8 @@ class DataBlock:
result = self.__createFITS0( iRA, iDEC)
self.__logger.debug("createFITS: exiting")
return result
def getYtObj(self, relFITSFilePath, product):
def getYtObj(self, relFITSFilePath, product, coord):
self.__logger.debug("getYtObj: entering")
result = {"status": False, "message": "", "result": None}
if not self.is3D():
......@@ -995,34 +995,27 @@ class DataBlock:
try:
absFITSFilePath = DataBlock.getFITSFilePrefix() + relFITSFilePath
absOBJFilePath = DataBlock.getOBJFilePrefix() + product
#create cube by extracting data from the fits
cube= fits.getdata(absFITSFilePath)
cube = cube.squeeze()
cube[np.isnan(cube)] = np.nanmin(cube)
cube.shape
Nsigma = 0.1
#define the delimeter
reduce=0.4 # 20% of the nb of x and y channels (to avoid the edge noise)
schrink = 1 # velocity axis: new v-axis size is RA/DEC-axis size / schrink
chan_min = 86 # 0 #121 # 24
chan_max = 100 # len(cube[:,1,1]) #233 # 86
cube.shape
rms=cube.std()
cube.clip(Nsigma*rms)
subcube = cube[chan_min:chan_max,:,:]
print(subcube.shape)
print(rms)
max_shape=max(subcube.shape)
chan_min = coord['iFREQ0'] # 0 #121 # 24
chan_max = coord['iFREQ1'] # len(cube[:,1,1]) #233 # 86
dec_min = coord['iDEC0']
dec_max = coord['iDEC1']
ra_min = coord['iRA0']
ra_max = coord['iRA1']
subcube = cube[chan_min:chan_max,dec_min:dec_max,ra_min:ra_max]
rms=subcube.std()
Nsigma = 2
subcube.clip(Nsigma*rms)
data = dict(density = subcube)
ytds = yt.load_uniform_grid(data, subcube.shape)
print("Dim")
print(ytds.domain_dimensions)
ytds.periodicity = (True,)*3
dd = ytds.all_data()
......@@ -1030,7 +1023,7 @@ class DataBlock:
surf = ytds.surface(region, "density", Nsigma*rms)
surf.export_obj(absOBJFilePath)
result = {"status": True, "message": "", "result": product}
except Exception as e:
result["message"]="An exception occurred with message {%s}" % e
result["status"]= False
......
......@@ -380,15 +380,15 @@ class DataManagerImpl :
#
#
#
def getYtObj(self,relFITSFilePath,product):
def getYtObj(self,relFITSFilePath,product,coord):
self.__logger.debug("getYtObj : entering")
self.__logger.debug("relFITSFilePath = %r, product= %r" % (relFITSFilePath,product))
self.__logger.debug("relFITSFilePath = %r, product= %r, (%i,%i,%i,%i,%i,%i)" % (relFITSFilePath,product,coord['iRA0'],coord['iRA1'],coord['iDEC0'],coord['iDEC1'],coord['iFREQ0'],coord['iFREQ1']))
result = self.__checkPresence(relFITSFilePath)
if result :
result = self.__dataBlocks[relFITSFilePath].getYtObj(relFITSFilePath,product)
result = self.__dataBlocks[relFITSFilePath].getYtObj(relFITSFilePath,product,coord)
self.__logger.debug("getYtObj : exiting")
return result
#
#
# End of the DataManagerImpl class
......
......@@ -1063,7 +1063,8 @@ def getYtObj():
try:
body = byteify(json.loads(request.body.read()))
relFITSFilePath = rebuildFilename(body['relFITSFilePath'])
result = dm.getYtObj(relFITSFilePath, body['product'])
coord={"iRA0":getIntValue(body['iRA0']),"iRA1":getIntValue(body['iRA1']),"iDEC0":getIntValue(body['iDEC0']),"iDEC1":getIntValue(body['iDEC1']),"iFREQ0":getIntValue(body['iFREQ0']),"iFREQ1":getIntValue(body['iFREQ1'])}
result = dm.getYtObj(relFITSFilePath,body['product'], coord)
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback.print_exc()
......
......@@ -160,11 +160,18 @@ var clienthttp = {
callback(error, response, body);
});
},
getYtObj : function(relFITSFilePath, callback) {
getYtObj : function(relFITSFilePath,iRA0,iRA1,iDEC0,iDEC1,iFREQ0,iFREQ1,callback) {
// retrieve the product name, i.e. the simple filename without extension nor prefix.
var product = path.parse(relFITSFilePath).name;
let input = {"relFITSFilePath": relFITSFilePath, "product":product};
let input = {"relFITSFilePath": relFITSFilePath,
"product":product,
"iRA0":iRA0,
"iRA1":iRA1,
"iDEC0":iDEC0,
"iDEC1":iDEC1,
"iFREQ0":iFREQ0,
"iFREQ1":iFREQ1};
request.post(this.server+"/getYtObj", {json: true,body:input}, function(error, response, body){
callback(error, response, body);
});
......@@ -756,7 +763,8 @@ router.post('/measureContour', function(req, res, next){
router.get("/getYtObj", function(req, res, next) {
console.log('router.get("/", function(req, res, next) { : entering ');
clienthttp.getYtObj(req.query.relFITSFilePath,(error, response, body) => {
clienthttp.getYtObj(req.query.relFITSFilePath,req.query.iRA0, req.query.iRA1, req.query.iDEC0,
req.query.iDEC1, req.query.iFREQ0, req.query.iFREQ1,(error, response, body) => {
console.log("getYtObj callback : entering");
if (error) {
console.log(error);
......@@ -764,16 +772,16 @@ router.get("/getYtObj", function(req, res, next) {
else {
console.log("body result "+body["result"]);
var gltfFile = OBJ_ROOT_DIR+"/"+body["result"]+".gltf";
//create gltfFile
obj2gltf(OBJ_ROOT_DIR+"/"+body["result"]+".obj").then(function(gltf) {
const data = Buffer.from(JSON.stringify(gltf));
fs.writeFileSync(gltfFile, data);
}).then(function(){
}).then(function(){
console.log(gltfFile);
res.render("getYtObj",{gltfFile:URLRoot(req.headers.referer)+"/"+body["result"]+".gltf"});
});
}
console.log("getYtObj callback : exiting");
});
......
<!DOCTYPE html>
<html>
<head>
<head>
<title>ThreeJS cube viewer</title>
<style>
body { margin: 0; }
......@@ -12,44 +12,52 @@
<script src="../javascript/GLTFLoader.js"></script>
<script src="../javascript/OrbitControls.js"></script>
<script>
<script>
// Load 3D Scene
var scene = new THREE.Scene();
var scene = new THREE.Scene();
// Load Camera Perspektive
var camera = new THREE.PerspectiveCamera( 25, window.innerWidth / window.innerHeight, 1, 20000 );
var camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 20000 );
camera.position.set( 1, 1, 20 );
//camera.position.x = 50;
//camera.position.z = - 50;
//camera.position.y = 30;
//camera.target = new THREE.Vector3();
// Load a Renderer
var renderer = new THREE.WebGLRenderer({ alpha: false });
renderer.setClearColor( 0xC5C5C3 );
var renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor( 0x000000 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Load the Orbitcontroller
var controls = new THREE.OrbitControls( camera, renderer.domElement );
var controls = new THREE.OrbitControls( camera, renderer.domElement );
// Load Light
var ambientLight = new THREE.AmbientLight( 0xcccccc );
scene.add( ambientLight );
var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.set( 0, 1, 1 ).normalize();
scene.add( directionalLight );
scene.add( directionalLight );
//Load axis
var axesHelper = new THREE.AxesHelper( 5 );
scene.add( axesHelper );
// glTf Loader
var loader = new THREE.GLTFLoader();
loader.load( '<%=gltfFile%>', function ( gltf ) {
var object = gltf.scene;
gltf.scene.scale.set( 2, 2, 2 );
gltf.scene.position.x = 0; //Position (x = right+ left-)
var loader = new THREE.GLTFLoader();
loader.load( '<%=gltfFile%>', function ( gltf ) {
var object = gltf.scene;
gltf.scene.scale.set( 2, 2, 2 );
gltf.scene.position.x = 0; //Position (x = right+ left-)
gltf.scene.position.y = 0; //Position (y = up+, down-)
gltf.scene.position.z = 0; //Position (z = front +, back-)
scene.add( gltf.scene );
});
});
function animate() {
render();
......@@ -62,6 +70,6 @@
render();
animate();
</script>
</script>
</body>
</html>
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