picaso icon indicating copy to clipboard operation
picaso copied to clipboard

5/9 Hackday: Add resort rebin capability to simple forward model calculation (outside of climate calculation)

Open natashabatalha opened this issue 11 months ago • 1 comments

Problem:

If user runs

#second the correlated k table
opacity_ck = jdi.opannection(ck=True,
                             ck_db=ck_db, deq=True, gasses_fly=[list of molecules...]
                            )

it would pull the HDF5 individual molecule opacity files BUT the code would break because opacityclass.molecular_opa is not defined

https://github.com/natashabatalha/picaso/blob/bfefda1ef78ea220b7cb8ae988d7f0b7fc53dd45/picaso/optics.py#L251C1-L256C41

The only two options here are to sum all the opacities when ngauss==1 and if there are gauss ck points it just sums the gauss opacities (does not take into account mixing ratios).

Code addition

In RetrieveCKs if deq=True:

https://github.com/natashabatalha/picaso/blob/bfefda1ef78ea220b7cb8ae988d7f0b7fc53dd45/picaso/optics.py#L634 add:

self.gases_fly=gases_fly

Now go through function passing and eliminate gases_fly as an input variable to those functions. For example, get_opacities_deq_onfly and mix_my_opacities_gasesfly

Also eliminate bundle to Last, delete bundle as an input to get_opacities_deq_onfly and mix_my_opacities_gasesfly

Right now bundle is being used to get mixing ratios however, those are already in atmosphere class as :

atmosphere.layer['mixingratios']

so you can change these lines https://github.com/natashabatalha/picaso/blob/bfefda1ef78ea220b7cb8ae988d7f0b7fc53dd45/picaso/optics.py#L1150C1-L1152C75

to

        mixes = []
        df_atmo = atmosphere.layer['mixingratios'] #bundle.inputs['atmosphere']['profile']
        for imol in gases_fly: 
            mixes += [df_atmo[imol].values]
 

Then can add another piece to this elif statement:

if isisntance(opacityclass.gases_fly, list):
    get_opacities = opacityclass. get_opacities_deq_onfly 

Finally, do a grep on get_opacities_deq_onfly and mix_my_opacities_gasesfly and remove the gases_fly and bundle input throughout the code.

natashabatalha avatar Jan 23 '25 18:01 natashabatalha

All done and merged to #28

  • [x] This tutorial needs needs to be updated with the resortrebin/preweighted option added as input to oppanection. Also this notebook should now show resortrebin vs preweighted vs monochromatic
  • [x] Still need to fix the CIA problem which currently looks for all molecules in gases_fly

natashabatalha avatar Feb 08 '25 00:02 natashabatalha