New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulation setting that switches or skips calculations #76

Open
mikofski opened this Issue Oct 25, 2016 · 2 comments

Comments

1 participant
@mikofski
Member

mikofski commented Oct 25, 2016

Implement methods to optionally skip a calculation and link outputs by passing a flag to the simulation settings without requiring an entirely new calculation

For example, the option to use aoi diffuse modifiers or not could depend on a simulation setting, therefore aoi modifier would be linked to aoi diffuse modifier

@mikofski mikofski self-assigned this Oct 25, 2016

@mikofski mikofski changed the title from Simulation setting that switched out skips calculations to Simulation setting that switches or skips calculations Nov 3, 2016

@mikofski

This comment has been minimized.

Member

mikofski commented Nov 4, 2016

Assuming that #63 is complete, then in calculation parameter formula can be a dictionary.

EG: spectral calculation with optional formulas

spectral = CalcParameter(
    dependencies=[solarposition, skymodel],
    formula=['f_sapm', 'f_fs', 'fspectrl2'],
    args={'f_sapm': {
        'data': {'time': 'time'},
        'output': {'AM': 'airmass'}
    }, 'f_fs': {
        'data': {'time': 'time'},
        'output': {'AM': 'airmass', 'pwat': 'watervap'}
    }, 'f_spectrl2': {
        'data': {'time': 'time'},
        'output': {'eqe': 'quantumeff', 'pwat': 'watervap', 'aod': 'aod', 'alpha': 'angstrom_alpha'}
    }},
    returns: ['spectral_shift'],
    skip: [1]  # a skip value for each returns, could be set to a value from any dependent calculation
)

Then in the simulation layer, a SimParameter can have the calculation option attribute.

settings = SimParameter(...
    calc_options={'spectral': None}
)  # None means use the skip value

~ or ~

settings = SimParameter(...
    calc_options={'spectral': 'f_sapm'}
)  # None means use the f_sapm formula and args!

Here's a sketch @anomam and I drew in our simeng2 meeting on 11/3:
img_20161103_155946

@mikofski

This comment has been minimized.

Member

mikofski commented Nov 4, 2016

For now, we can do this by just using a different calculation class, which is more tedious, but equally effective, EG:

class SAPMSpectralCalc(calculations.Calc):
    dependencies = ['blah']
    static = [{'formula': 'f_sapm', 'args': {'data': {'times': 'times'}, 'outputs': {'am': 'am'}}, 'returns: ['m']}]

class FirstSolarSpectralCalc(calculations.Calc):
    dependencies = ['blah']
    static = [{
        'formula': 'f_fs',
        'args': {'data': {'times': 'times'},
                 'outputs': {'pwat': 'pwat', 'am': 'am'}},
        'returns: ['m']
    }]

etc. then just create more than one model, but swap out the desired calculation. In your application, you can switch between models based on the calc options desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment