Skip to content
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

Importing InVals do not show up in cases #8

Closed
MariovdBerg opened this issue Feb 26, 2024 · 3 comments
Closed

Importing InVals do not show up in cases #8

MariovdBerg opened this issue Feb 26, 2024 · 3 comments

Comments

@MariovdBerg
Copy link

Hi,

I'm trying to run an analysis on a set of input and output data (.csv-files). I'm probably overlooking something, but when I try to do a multi_plot the InVar somehow have no distribution. When checking the cases, I found that they had no InVars and only OutVars.

How do I properly load InVars if I don't want to run an actual simulation? I'm working in Jupyter Notebook, see snippet below.
I've attached the csv files I use:
test_invars.csv
test_outvars.csv

import monaco as mc

def template_preprocess(case):
    
    # This is where I think I'm doing something wrong

    variables = {
        'In1' : case.invals['Var1'].val,
        'In2' : case.invals['Var2'].val,
        'In3' : case.invals['Var3'].val,
        'In4' : case.invals['Var4'].val,
        'In5' : case.invals['Var5'].val,
        'In6' : case.invals['Var6'].val,
        'In7' : case.invals['Var7'].val,
        'In8' : case.invals['Var8'].val,
        'In9' : case.invals['Var9'].val,
        'In10' : case.invals['Var10'].val,
        'In11' : case.invals['Var11'].val,
        'In12' : case.invals['Var12'].val,
        'In13' : case.invals['Var13'].val,
        'In14' : case.invals['Var14'].val,
        'In15' : case.invals['Var15'].val,
        'In16' : case.invals['Var16'].val,
        'In17' : case.invals['Var17'].val,
        'In18' : case.invals['Var18'].val,
        'In19' : case.invals['Var19'].val,
        'In20' : case.invals['Var20'].val,
        'In21' : case.invals['Var21'].val,
        'In22' : case.invals['Var22'].val,
        'In23' : case.invals['Var23'].val,
        'In24' : case.invals['Var24'].val
    }
    
    return variables

def template_run(variables):
    
    # We do nothing with the input so we just return the variables
    
    return variables

def template_postprocess(case, variables):
    
    # Don't actually have any output so simply add OutVals only
    
    case.addOutVal(name='Out1', val=case.outvals['Out1'].val)
    case.addOutVal(name='Out2', val=case.outvals['Out2'].val)
    case.addOutVal(name='Out3', val=case.outvals['Out3'].val)

fcns = {'preprocess' : template_preprocess,
        'run'        : template_run,
        'postprocess': template_postprocess}

ndraws = 128
sim = mc.Sim(name='Test', ndraws=ndraws, fcns=fcns,
             firstcaseismedian=False,
             singlethreaded=True,
             savecasedata=False, savesimdata=False,
             verbose=True, debug=False)

sim.importInVars("test_invars.csv")
sim.importOutVars("test_outvars.csv")

plot_invar = sim.invars['Var18']
plot_outvar = sim.outvars['Out1']
fig, axs = mc.multi_plot([plot_invar, plot_outvar], rug_plot=True, cov_plot=True)

The plot I get is below. The invars exist because they can be plotted.
test_plot

@scottshambaugh
Copy link
Owner

scottshambaugh commented Feb 26, 2024

Thanks for reporting @MariovdBerg! I can confirm your code is good and this was a bug, and I just published a hotfix release to fix it. If you do a pip install -U monaco to update to v0.11.7, this should be working now.

@scottshambaugh
Copy link
Owner

scottshambaugh commented Feb 26, 2024

Please note that there will be no analytical input distribution plotted with it, since it was imported from file. You could probably add that in by modifying var.dist and var.distkwargs parameters directly if you wanted to, but I haven't tested that workflow.

@MariovdBerg
Copy link
Author

Please note that there will be no analytical input distribution plotted with it, since it was imported from file. You could probably add that in by modifying var.dist and var.distkwargs parameters directly if you wanted to, but I haven't tested that workflow.

Plots are working! Thank you for the quick hotfix. I have no need for a distribution plot :) but I might try it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants