[Debian-astro-commits] [gyoto] 62/221: yorick: when raytracing, support using arbitraty size arrays as indices.

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

thibaut pushed a commit to branch master
in repository gyoto.

commit 97a0e08cea0bb46c408f6d956d875fe4b2c3723d
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Tue Oct 21 13:03:36 2014 +0200

    yorick: when raytracing, support using arbitraty size arrays as indices.
---
 yorick/check-scenery.i | 10 ++++++++++
 yorick/gyoto.i         | 31 +++++++++++++++++++++----------
 yorick/gyoto_Idx.C     | 11 ++++++-----
 yorick/gyoto_Scenery.C | 17 ++++++++++++-----
 4 files changed, 49 insertions(+), 20 deletions(-)

diff --git a/yorick/check-scenery.i b/yorick/check-scenery.i
index 5432e96..9e12a23 100644
--- a/yorick/check-scenery.i
+++ b/yorick/check-scenery.i
@@ -226,6 +226,8 @@ r1=8:25:4;
 r2=2:-2:3;
 v1=[1, 4, 16];
 v2=[15, 20, 22];
+s1=[[1, 2], [3, 4]];
+s2=[[[12, 13], [14, 15]], [[1, 2], [3, 4]], [[10, 11], [16, 17]], [[7, 8], [20, 22]]];
 
 doing, "Integrating subfield...";
 data2=sc(r1, r2, );
@@ -244,6 +246,14 @@ if (anyof(data2 != data(v1, v2, ))) error, "result differ";
 done;
 
 doing, "Integrating subfield...";
+data2=sc(s1, s2, );
+done;
+
+doing, "Comparing...";
+if (anyof(data2 != data(s1, s2, ))) error, "result differ";
+done;
+
+doing, "Integrating subfield...";
 data2=sc(r1, v2, );
 done;
 
diff --git a/yorick/gyoto.i b/yorick/gyoto.i
index 5d7d845..7b34928 100644
--- a/yorick/gyoto.i
+++ b/yorick/gyoto.i
@@ -575,16 +575,27 @@ extern gyoto_Scenery;
      Ray-traced data is retrieved calling the object like a function
      with no keyword:
         data = scenery ();
-     or data = scenery (irange, jrange, quant )
-     
-    IRANGE and JRANGE are either scalars (i, j) or ranges in the usual
-    form min:max:step. QUANT is an array of Yorick strings where each
-    element selects one quantity to retrieve (see the QUANTITIES
-    member above). QUANT may be void to use the quantities already set
-    in the Scenery or the default for the Astrobj. If specifyng QUANT,
-    DATA will be a MxNxP double array, where P=numberof(QUANT) and
-    DATA(,,i) will contain the value of the quantity specifeid by
-    QUANT(i).
+     or data = scenery (ispec, jspec, quant )
+     or data = scenery (alpha, delta, quant )
+
+    ISPEC and JSPEC are about anything that can be use to index an
+    array (except range functions, wildcards and rubber indices):
+    scalar integers, ranges (imin:imax:step), or arrays of
+    integers. The result is that
+       scenery() (ispec, jspec, ) == scenery(ispec, jspec, );
+    Indices are in the range 1 to scenery.screen().resolution().
+
+    ALPHA and DELTA are double scalars or arrays of scalars. If they
+    are both arrays, they must have the same dimensions. They are used
+    as angles to address the screen. Angles are normally in the range
+    [-0.5,0.5]*scenery.screen().fov().
+
+    QUANT is an array of Yorick strings where each element selects one
+    quantity to retrieve (see the QUANTITIES member above). QUANT may
+    be void to use the quantities already set in the Scenery or the
+    default for the Astrobj. If specifyng QUANT, DATA will be a MxNxP
+    double array, where P=numberof(QUANT) and DATA(,,i) will contain
+    the value of the quantity specified by QUANT(i).
 
     QUANTITIES may also be a scalar to retrieve a single
     quantity.
diff --git a/yorick/gyoto_Idx.C b/yorick/gyoto_Idx.C
index 8e7f34c..556a22b 100644
--- a/yorick/gyoto_Idx.C
+++ b/yorick/gyoto_Idx.C
@@ -113,16 +113,15 @@ YGyoto::Idx::Idx(int iarg, int res) :
 
 
     _nel=(_range[1]-_range[0]+_range[2])/_range[2];
+    _dims[0]=1; _dims[1]=_nel;
     return;
   }
-  if (yarg_rank(iarg) > 0) {
-    if (yarg_number(iarg)==1){
+  if (yarg_number(iarg)==1){
+    if (yarg_rank(iarg) > 0) {
       _is_list=1;
       _idx = ygeta_l(iarg, &_nel, _dims);
       return;
     }
-  }
-  if (yarg_number(iarg)==1) {
     _is_scalar=1;
     long val=ygets_l(iarg);
     if (val>res) y_error("max index too large");
@@ -130,10 +129,10 @@ YGyoto::Idx::Idx(int iarg, int res) :
     _range[0]=_range[1]=val;
     _range[2]=1;
     _nel=1;
+    _dims[0]=0;
     return;
   }
   if (yarg_number(iarg)==2) {
-    _is_scalar=1;
     _is_double=1;
     _buf=ygeta_d(iarg, &_nel, _dims);
     _dval=_buf[0];
@@ -150,6 +149,8 @@ YGyoto::Idx::Idx(int iarg, int res) :
       _range[1]=res;
       _range[2]=1;
       _nel=res;
+      _dims[0]=1;
+      _dims[1]=_nel;
       return;
   }
   y_error("unsupported range syntax");
diff --git a/yorick/gyoto_Scenery.C b/yorick/gyoto_Scenery.C
index 55a1489..6fb30da 100644
--- a/yorick/gyoto_Scenery.C
+++ b/yorick/gyoto_Scenery.C
@@ -184,21 +184,24 @@ extern "C" {
 	is_double=true;
 	nelem=i_idx.getNElements();
 	long const *idims=i_idx.getDims();
-	for (int m=0; m<idims[0]+1; ++m) dims[m]=idims[m];
 	if (j_idx.getNElements() != nelem) {
 	  if (nelem==1) {
 	    nelem=j_idx.getNElements();
 	    idims=j_idx.getDims();
-	    for (int m=0; m<idims[0]+1; ++m) dims[m]=idims[m];
 	  }
 	  else throwError("alpha and delta must be conformable");
 	}
+	for (int m=0; m<idims[0]+1; ++m) dims[m]=idims[m];
       } else {
 	nelem=i_idx.getNElements()*j_idx.getNElements();
 	dims[0]=0;
 	if (precompute)       dims[++dims[0]]=16;
-	if (i_idx.getNDims()) dims[++dims[0]]=i_idx.getNElements();
-	if (j_idx.getNDims()) dims[++dims[0]]=j_idx.getNElements();
+	if ( (precompute + i_idx.getDims()[0]+j_idx.getDims()[0]) >= Y_DIMSIZE )
+	  throwError("Too many dimensions");
+	long const *idims=i_idx.getDims();
+	for (int m=1; m<=idims[0];++m) dims[++dims[0]]=idims[m];
+	idims=j_idx.getDims();
+	for (int m=1; m<=idims[0];++m) dims[++dims[0]]=idims[m];
       }
 
       long nk = 0; int rquant = 0; ystring_t * squant = NULL;
@@ -267,7 +270,11 @@ extern "C" {
       if (has_bsp) nk+=nbnuobs-1;
       if (!has_sp && !has_bsp) nbnuobs=0;
 
-      if ( !precompute && ((rquant>=1)||has_sp||has_bsp) ) dims[++dims[0]]=nk;
+      if ( !precompute && ((rquant>=1)||has_sp||has_bsp) ) {
+	++dims[0];
+	if (dims[0] >=Y_DIMSIZE) throwError("Too many dimensions");
+	dims[dims[0]]=nk;
+      }
 
       GYOTO_DEBUG << "precompute=" << precompute << ", nk=" << nk
 		  << ", nbnuobs="<<nbnuobs << ", data=ypush_d({"<< dims[0]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git



More information about the Debian-astro-commits mailing list