csdms-contrib / slepian_alpha

Scalar spherical-harmonic analysis and Slepian functions
GNU General Public License v2.0
26 stars 31 forks source link

threej('demo1') does not work #3

Closed FlorianPfaff closed 8 years ago

FlorianPfaff commented 8 years ago

First off, it is really great to see such a good collection of important functions in Matlab to deal with functions on spheres. I am not sure if you are interested in reports of issues, but I am posting just in case - just close the issue if you're not interested.

So after playing around a bit and getting some functions to work (such as xyz2plm), I am having a bit of trouble with threej.m

For me, even the demo threej('demo1') does not work (output at the end of this post). Basically, it crashes because L is set to -1 in line 180 of threej which induces an empty matr in addmout and thus an empty ranges in matranges. Line 181 says something about failing on purpose, but since it crashes before any files are created in WIGNER, nothing is different in any subsequent calls (and it's not in a try-catch block, so I'd assume that it should not actually produce a real error that ends the entire execution).

If you have any information on what could be wrong, I'd appreciate that - thanks. (I hope it's not some loss of backwards compatibility of Matlab again, I'm using 2016a on Windows 10).

Greetings

Florian

threej('demo1') Index exceeds matrix dimensions.

Error in matranges (line 25) hulp1(1)=ranges(1);

Error in addmout (line 29) EM=matranges(matr(:)')';

Error in wignercycle (line 59) [EM,EL,mz,blkm,dblk]=addmout(L);

Error in threej (line 182) wignercycle(L);

Error in threej (line 290) difer(full(threej([8 7 6 5 4],6,5,3,2,-5))-...

fjsimons commented 8 years ago

Hi Florian,

I'm afraid I don't have a whole lot of time for troubleshooting these days, but over time, we will get there so all your comments are much appreciated.

You need to make sure to make a directory

$IFILES/WIGNER

and then run

wignercycle(L)

for some high enough value of L. That will create e.g.

WIGNER3J-10-sym.mat

a file which is then properly read by THREEJ etc.

The reason that I make the program fail on purpose is that you need to decide how how you want to generate a database for - high enough to do what you need, but not too high (it takes time). And you don't want to generate one for every maximum degree that you ever need, since the code will check if you have values "up to" a certain high enough degree.

I just verified that making a new one, e.g.. up to 10, will produce correct results for THREEJ with values up to ten.

The demo1 is a very demanding piece of work that assumes you have a high value of coefficients precalculated, e.g. I have (for example) prestored

-rw-rw-r--. 1 fjsimons fjsimons 38027 Apr 11 16:09 WIGNER3J-10-sym.mat -rw-rw-r--. 1 fjsimons fjsimons 313384 Jun 15 2010 WIGNER3J-16-sym.mat -rw-rw-r--. 1 fjsimons fjsimons 7772040 May 22 2011 WIGNER3J-32-sym.mat -rw-rw-r--. 1 fjsimons fjsimons 53764112 May 30 2011 WIGNER3J-48-sym.mat

and then, in the non-symmetrical storage scheme (less efficient), some examples are:

-rw-rw-r--. 1 fjsimons fjsimons 54814208 Mar 3 2007 WIGNER0JCS-300-S -rw-rw-r--. 1 fjsimons fjsimons 54814208 Mar 3 2007 WIGNER0JCS-300-C -rw-rw-r--. 1 fjsimons fjsimons 73770000 Jan 26 2007 WIGNER3JCS-28-S -rw-rw-r--. 1 fjsimons fjsimons 73770000 Jan 26 2007 WIGNER3JCS-28-C -r--r--r--. 1 fjsimons fjsimons 97535568 Jan 11 2007 WIGNER6JCS-20-S -r--r--r--. 1 fjsimons fjsimons 97535568 Jan 11 2007 WIGNER6JCS-20-C -rw-rw-r--. 1 fjsimons fjsimons 102977776 Aug 18 2006 WIGNER3JCS-30-S -rw-rw-r--. 1 fjsimons fjsimons 102977776 Aug 18 2006 WIGNER3JCS-30-C -rw-rw-r--. 1 fjsimons fjsimons 168258400 Jan 25 2007 WIGNER6JCS-22-S -rw-rw-r--. 1 fjsimons fjsimons 168258400 Jan 25 2007 WIGNER6JCS-22-C -rw-rw-r--. 1 fjsimons fjsimons 252257008 Mar 3 2007 WIGNER0JCS-500-S -rw-rw-r--. 1 fjsimons fjsimons 252257008 Mar 3 2007 WIGNER0JCS-500-C -rw-rw-r--. 1 fjsimons fjsimons 277369864 Jan 26 2007 WIGNER6JCS-24-S -rw-rw-r--. 1 fjsimons fjsimons 277369864 Jan 26 2007 WIGNER6JCS-24-C -rw-r--r--. 1 fjsimons fjsimons 416896888 Sep 22 2006 WIGNER3JCS-40-S -rw-r--r--. 1 fjsimons fjsimons 416896888 Sep 22 2006 WIGNER3JCS-40-C -rw-rw-r--. 1 fjsimons fjsimons 440001368 Jan 26 2007 WIGNER6JCS-26-S -rw-rw-r--. 1 fjsimons fjsimons 440001368 Jan 26 2007 WIGNER6JCS-26-C -rw-rw-r--. 1 fjsimons fjsimons 675370264 Jan 26 2007 WIGNER6JCS-28-S -rw-rw-r--. 1 fjsimons fjsimons 675370264 Jan 26 2007 WIGNER6JCS-28-C -rw-rw-r--. 1 fjsimons fjsimons 1007456728 Jan 25 2007 WIGNER6JCS-30-S -rw-rw-r--. 1 fjsimons fjsimons 1007456728 Jan 25 2007 WIGNER6JCS-30-C -rw-rw-r--. 1 fjsimons fjsimons 1016608312 Apr 26 2007 WIGNER3JCS-48-S -rw-rw-r--. 1 fjsimons fjsimons 1016608312 Apr 26 2007 WIGNER3JCS-48-C -rw-r--r--. 1 fjsimons fjsimons 1241752344 Oct 28 2006 WIGNER3JCS-50-S -rw-r--r--. 1 fjsimons fjsimons 1241752344 Oct 28 2006 WIGNER3JCS-50-C -rw-rw-r--. 1 fjsimons fjsimons 3039996752 Oct 9 2006 WIGNER3JCS-60-S -rw-rw-r--. 1 fjsimons fjsimons 3039996752 Oct 9 2006 WIGNER3JCS-60-C -rw-rw-r--. 1 fjsimons fjsimons 5388476224 Feb 4 2007 WIGNER6JCS-40-S -rw-rw-r--. 1 fjsimons fjsimons 5388476224 Feb 4 2007 WIGNER6JCS-40-C

FlorianPfaff commented 8 years ago

Dear Frederik,

thanks a lot! With a bit of playing around I also happened to find out that calling wignercycle with a sufficiently high L beforehand allows threej to run correctly. However, I still thought this was weird behavior, because if the function errors on purpose, it would be natural to throw a comprehensive error using the Matlab error() function.

Anyways, thanks a lot for your help - you are right that there is no perfect way to deal with this automatically as precomputation is expensive and that the user should know best which one should be precomputed.

Greetings

Florian

fjsimons commented 8 years ago

Thanks, Florian, I'm glad that helps. If only I was a professional, then I would have time for proper fixes of all known behaviors. You stumbled upon a "quick" fix that I put in there just so people would notice. Putting this stuff on GitHub, though was done precisely to be able to streamline things for the community at large, so it's now on my to-do-list.