lo-co / atm-py

Set of python packages for processing atmospheric data.
MIT License
0 stars 7 forks source link

Mie code #5

Open lo-co opened 8 years ago

lo-co commented 8 years ago

So, there is Mie code in a couple of places in the libarary: in the POPS instrument folder and in it's own folder. The POPS implementation is kind of chaotic and not well documented while the other library is pulled from an external library and likely needs some investigating. Gavin - you have done a lot of work with Mie code - do you think you could implement something? My suggestion is to create a new branch based on the ''NewStructure'' branch and add routines in their own folder under aerosols/phys/opt (I realize that is not there right this moment, so we need to add this too).

GavinMcMeeking commented 8 years ago

I've done some with Mie output, but not really modified or dug into the code itself much. I can take a look though.

lo-co commented 8 years ago

Well, maybe testing the existing code is sufficient? Make sure it works against a variety of cases? I think this implementation is based on Bohren and Huffman?

lo-co commented 8 years ago

I just created your very own branch from NewStructure called Gavin - your very own playground...

GavinMcMeeking commented 8 years ago

I can definitely do that. I have the version Chris Cappa implemented in Igor that I can test against, and he has done extensive testing against the original code from B&H.

lo-co commented 8 years ago

Oh yeah - added you to collaborators... don't break shit

hagne commented 8 years ago

There is no real mie in the POPS foulder. The module named mie.py in the POPS folder is using the bhmie.py in the main/mie folder and takes care of the particular POPS symmetry to simulate what POPS would see. bhmie.py is heavily tested against the http://omlc.org/calc/mie_calc.html Unfortunately I did not write nice testing routines. In general, bhmie is kind of a mess. At some point I tried to convert it to a class but basically got stuck half way through. I hoped to avoid some of the calculations when only particular parameters were calculated and therefore minimize computational requirements. I don't think this is actually going to work. Maybe we should make it a function again and return a dictionary with all relevant parameters.

lo-co commented 8 years ago

Hmmmm...I will let Gavin take a look at this and say something. I found the layout of bhmie to be incredibly confusing (and hence not particularly maintainable).

But, on another note, this is a good instance of adding unit tests. Python has a (built-in unit test framework)[https://docs.python.org/3/library/unittest.html]. Scipy is using (nose)[https://nose.readthedocs.org/en/latest/] which is also mentioned in the Python unittest section. Ultimately, this is how we want to demonstrate that these things work and we should try to be familiar with them and hopefully inspire confidence in others to use them.

hagne commented 8 years ago

Any suggestions which of the two unit testing we should use?

lo-co commented 8 years ago

Yo...so, I worked with this some yesterday and the unittest object provided by python is pretty easy. You can see an example of this here; the test is very simple and I am just testing whether the temperature and pressure I specify are what I expect - alls well.

I think that nose is going to be the way to go as it is a simple extension of the test framework - we can use generators in this to run multiple tests, we can run tests across the entire project (I think), there is no need to import in the test files, etc, etc.

I will let you know what I think and then I would like to hear what you think.