void EnergyPlotter::plotData(const QString& outFilename) { if (m_ui.leftThigh->isChecked()) plotData(0, outFilename + "-leftthigh"); if (m_ui.rightThigh->isChecked()) plotData(1, outFilename + "-rightthigh"); if (m_ui.leftLowerLeg->isChecked()) plotData(2, outFilename + "-leftlower"); if (m_ui.rightLowerLeg->isChecked()) plotData(3, outFilename + "-rightlower"); }
void ClsFEGroupPlot::update() { #ifdef DEBUG_CLSFEGROUPPLOT cout << "ClsFEGroupPlot::update()" << endl; #endif plotData(); };
void qfit::startFitClicked() { if(filePath->text().isEmpty()) { appendLog("Select a file to open!"); return; } double error = -1; // retrive error from the QLineEdit if(customError->isChecked()) { error = errorValue->text().toDouble(); if(error <= 0.0) { appendLog("Custom error is not valid, a default one of 1.0 will be used"); error = 1; } } if(Data::ReadFile(filePath->text().toLatin1().data(), xdata, ydata, yerrors, error)) { appendLog("Error opening file"); return; } // start fittools delete fit; if(error <= 0) fit = new FitTools(xdata, ydata, yerrors, fit_type); else fit = new FitTools(xdata, ydata, error, fit_type); fit->Fit(); printResult(); #ifdef Qwt6_FOUND plotData(); #endif }
/****************************************************************************** * This method is called when a reference target changes. ******************************************************************************/ bool BinAndReduceModifierEditor::referenceEvent(RefTarget* source, ReferenceEvent* event) { if(event->sender() == editObject() && event->type() == ReferenceEvent::ObjectStatusChanged) { plotData(); } return ParticleModifierEditor::referenceEvent(source, event); }
void MainWindow::timerEvent(QTimerEvent * event) { if (event->timerId() == _timer.timerId()) { plotData(); updateProgBar(); } else if(event->timerId() == _buffTimer.timerId()) { updateLabelText(); } else { QWidget::timerEvent(event); } }
void CQBarChart::emptyPlot() { #ifdef DEBUG_UI qDebug() << "-- in qwt3dPlot.cpp Plot3d::emptyPlot --"; #endif data = new double * [1]; data[0] = new double[1]; data[0][0] = 0; setScale(NULL, NULL); setData(data, 1, 1, 0); mTitle = (QString("")); mpPlot->showColorLegend(false); plotData(); }
void CQBarChart::setData(double** data, int columns, int rows, double valueZone) { #ifdef DEBUG_UI qDebug() << "-- in qwt3dPlot.cpp Plot3d::setData --"; #endif int j; mData.valueZone = valueZone; mData.columns = columns; mData.rows = rows; if (columns < rows) mData.maxItems = rows; else mData.maxItems = columns; if (mData.columns == 1) { double** dataExpand = new double * [2]; dataExpand[0] = new double[mData.rows]; dataExpand[1] = new double[mData.rows]; for (j = 0; j < rows; j++) { dataExpand[0][j] = data[0][j]; dataExpand[1][j] = data[0][j]; } mData.faktor = 4 * (mData.valueZone) / (mData.rows - 1); mData.columnAxeLength = ((mData.columns - 1) * mData.faktor) + 0.000001; mData.rowAxeLength = ((mData.rows - 1) * mData.faktor); mpPlot->loadFromData(dataExpand, mData.columns + 1, mData.rows, 0, mData.columnAxeLength, 0, mData.rowAxeLength); } else { mData.faktor = 4 * (mData.valueZone) / (mData.maxItems - 1); mData.columnAxeLength = ((mData.columns - 1) * mData.faktor); mData.rowAxeLength = ((mData.rows - 1) * mData.faktor); mpPlot->loadFromData(data, mData.columns, mData.rows, 0, mData.columnAxeLength, 0, mData.rowAxeLength); } plotData(); setSlider(); }
PlotStreams::PlotStreams(const QString &title, QVector<Stream*> streams, QWidget *parent) : QWidget(parent), m_custom_plot(this), m_streams(streams) { setWindowTitle(title); setAttribute(Qt::WA_DeleteOnClose); QHBoxLayout *layout = new QHBoxLayout; setLayout(layout); layout->addWidget(&m_custom_plot); // m_custom_plot.setTitle("Objective Value"); //graph(0)->addData(0,1); //graph(0)->addData(1,2); m_custom_plot.xAxis->setLabel("Time"); m_custom_plot.yAxis->setLabel("Value"); m_custom_plot.setAutoAddPlottableToLegend(true); m_custom_plot.legend->setVisible(true); m_custom_plot.setRangeDrag(Qt::Vertical); m_custom_plot.setRangeZoom(Qt::Vertical); plotData(); resize(800, 600); show(); }
void ClsFETimePlot::update() { #ifdef DEBUG_CLSFETIMEPLOT cout << "ClsFETimePlot::update()" << endl; #endif plotData(); };
/** * Name: main * * Description: * See usage statement (run program with '-h' flag). * * Parameters: * @param argc number of command line arguments * @param argv command line arguments */ int main( int argc, char **argv ) { CmdArgs cmd_args; // Command line arguments. int num_comps, num_dendrs; // Simulation parameters. int i, j, t_ms, step, dendrite; // Various indexing variables. struct timeval start, stop, diff; // Values used to measure time. double exec_time; // How long we take. // Accumulators used during dendrite simulation. // NOTE: We depend on the compiler to handle the use of double[] variables as // double*. double current, **dendr_volt; double res[COMPTIME], y[NUMVAR], y0[NUMVAR], dydt[NUMVAR], soma_params[3]; // Strings used to store filenames for the graph and data files. char time_str[14]; char graph_fname[ FNAME_LEN ]; char data_fname[ FNAME_LEN ]; FILE *data_file; // The output file where we store the soma potential values. FILE *graph_file; // File where graph will be saved. PlotInfo pinfo; // Info passed to the plotting functions. ////////////////////////////////////////////////////////////////////////////// // Parse command line arguments. ////////////////////////////////////////////////////////////////////////////// if (!parseArgs( &cmd_args, argc, argv )) { // Something was wrong. exit(1); } // Pull out the parameters so we don't need to type 'cmd_args.' all the time. num_dendrs = cmd_args.num_dendrs; num_comps = cmd_args.num_comps; printf( "Simulating %d dendrites with %d compartments per dendrite.\n", num_dendrs, num_comps ); ////////////////////////////////////////////////////////////////////////////// // Create files where results will be stored. ////////////////////////////////////////////////////////////////////////////// // Generate the graph and data file names. time_t t = time(NULL); struct tm *tmp = localtime( &t ); strftime( time_str, 14, "%m%d%y_%H%M%S", tmp ); // The resulting filenames will resemble // pWWdXXcYY_MoDaYe_HoMiSe.xxx // where 'WW' is the number of processes, 'XX' is the number of dendrites, // 'YY' the number of compartments, and 'MoDaYe...' the time at which this // simulation was run. sprintf( graph_fname, "graphs/p1d%dc%d_%s.png", num_dendrs, num_comps, time_str ); sprintf( data_fname, "data/p1d%dc%d_%s.dat", num_dendrs, num_comps, time_str ); // Verify that the graphs/ and data/ directories exist. Create them if they // don't. struct stat stat_buf; stat( "graphs", &stat_buf ); if ((!S_ISDIR(stat_buf.st_mode)) && (mkdir( "graphs", 0700 ) != 0)) { fprintf( stderr, "Could not create 'graphs' directory!\n" ); exit(1); } stat( "data", &stat_buf ); if ((!S_ISDIR(stat_buf.st_mode)) && (mkdir( "data", 0700 ) != 0)) { fprintf( stderr, "Could not create 'data' directory!\n" ); exit(1); } // Verify that we can open files where results will be stored. if ((data_file = fopen(data_fname, "wb")) == NULL) { fprintf(stderr, "Can't open %s file!\n", data_fname); exit(1); } else { printf( "\nData will be stored in %s\n", data_fname ); } if (ISDEF_PLOT_PNG && (graph_file = fopen(graph_fname, "wb")) == NULL) { fprintf(stderr, "Can't open %s file!\n", graph_fname); exit(1); } else { printf( "Graph will be stored in %s\n", graph_fname ); fclose(graph_file); } ////////////////////////////////////////////////////////////////////////////// // Initialize simulation parameters. ////////////////////////////////////////////////////////////////////////////// // The first compartment is a dummy and the last is connected to the soma. num_comps = num_comps + 2; // Initialize 'y' with precomputed values from the HH model. y[0] = VREST; y[1] = 0.037; y[2] = 0.0148; y[3] = 0.9959; // Setup parameters for the soma. soma_params[0] = 1.0 / (double) STEPS; // dt soma_params[1] = 0.0; // Direct current injection into soma is always zero. soma_params[2] = 0.0; // Dendritic current injected into soma. This is the // value that our simulation will update at each step. printf( "\nIntegration step dt = %f\n", soma_params[0]); // Start the clock. gettimeofday( &start, NULL ); // Initialize the potential of each dendrite compartment to the rest voltage. dendr_volt = (double**) malloc( num_dendrs * sizeof(double*) ); for (i = 0; i < num_dendrs; i++) { dendr_volt[i] = (double*) malloc( num_comps * sizeof(double) ); for (j = 0; j < num_comps; j++) { dendr_volt[i][j] = VREST; } } ////////////////////////////////////////////////////////////////////////////// // Main computation. ////////////////////////////////////////////////////////////////////////////// // Record the initial potential value in our results array. res[0] = y[0]; // Loop over milliseconds. for (t_ms = 1; t_ms < COMPTIME; t_ms++) { // Loop over integration time steps in each millisecond. for (step = 0; step < STEPS; step++) { soma_params[2] = 0.0; // Loop over all the dendrites. for (dendrite = 0; dendrite < num_dendrs; dendrite++) { // This will update Vm in all compartments and will give a new injected // current value from last compartment into the soma. current = dendriteStep( dendr_volt[ dendrite ], step + dendrite + 1, num_comps, soma_params[0], y[0] ); // Accumulate the current generated by the dendrite. soma_params[2] += current; } // Store previous HH model parameters. y0[0] = y[0]; y0[1] = y[1]; y0[2] = y[2]; y0[3] = y[3]; // This is the main HH computation. It updates the potential, Vm, of the // soma, injects current, and calculates action potential. Good stuff. soma(dydt, y, soma_params); rk4Step(y, y0, dydt, NUMVAR, soma_params, 1, soma); } // Record the membrane potential of the soma at this simulation step. // Let's show where we are in terms of computation. printf("\r%02d ms",t_ms); fflush(stdout); res[t_ms] = y[0]; } ////////////////////////////////////////////////////////////////////////////// // Report results of computation. ////////////////////////////////////////////////////////////////////////////// // Stop the clock, compute how long the program was running and report that // time. gettimeofday( &stop, NULL ); timersub( &stop, &start, &diff ); exec_time = (double) (diff.tv_sec) + (double) (diff.tv_usec) * 0.000001; printf("\n\nExecution time: %f seconds.\n", exec_time); // Record the parameters for this simulation as well as data for gnuplot. fprintf( data_file, "# Vm for HH model. " "Simulation time: %d ms, Integration step: %f ms, " "Compartments: %d, Dendrites: %d, Execution time: %f s, " "Slave processes: %d\n", COMPTIME, soma_params[0], num_comps - 2, num_dendrs, exec_time, 0 ); fprintf( data_file, "# X Y\n"); for (t_ms = 0; t_ms < COMPTIME; t_ms++) { fprintf(data_file, "%d %f\n", t_ms, res[t_ms]); } fflush(data_file); // Flush and close the data file so that gnuplot will fclose(data_file); // see it. ////////////////////////////////////////////////////////////////////////////// // Plot results if approriate macro was defined. ////////////////////////////////////////////////////////////////////////////// if (ISDEF_PLOT_PNG || ISDEF_PLOT_SCREEN) { pinfo.sim_time = COMPTIME; pinfo.int_step = soma_params[0]; pinfo.num_comps = num_comps - 2; pinfo.num_dendrs = num_dendrs; pinfo.exec_time = exec_time; pinfo.slaves = 0; } if (ISDEF_PLOT_PNG) { plotData( &pinfo, data_fname, graph_fname ); } if (ISDEF_PLOT_SCREEN) { plotData( &pinfo, data_fname, NULL ); } ////////////////////////////////////////////////////////////////////////////// // Free up allocated memory. ////////////////////////////////////////////////////////////////////////////// for(i = 0; i < num_dendrs; i++) { free(dendr_volt[i]); } free(dendr_volt); return 0; }
PetscErrorCode plotAll( Vector<LevelData<FArrayBox> *> &a_phi, Vector<LevelData<FArrayBox> *> &a_rhs, Vector<RefCountedPtr<LevelData<FArrayBox> > > &a_exact, Real a_errNorm[2], string a_fname, Real a_cdx, Vector<DisjointBoxLayout> &a_grids, Vector<int> &a_refratios, Vector<ProblemDomain> &a_domains, PetscCompGridPois &a_petscop, Vec a_x, int a_sub_id = -1 ) { CH_TIME("plotAll"); int nLev = a_phi.size(); PetscErrorCode ierr; Vector<LevelData<FArrayBox>* > plotData(nLev, NULL); if ( a_x ) { ierr = a_petscop.putPetscInChombo(a_x,a_phi); CHKERRQ(ierr); } for (int ilev=0;ilev<nLev;ilev++) { plotData[ilev] = new LevelData<FArrayBox>(a_grids[ilev],4*COMP_POIS_DOF,IntVect::Unit); } a_errNorm[0] = a_errNorm[1] = 0; Real dx = a_cdx; for (int ilev=0;ilev<nLev;ilev++,dx/=s_refRatio) { Interval phiInterval(0,COMP_POIS_DOF-1); a_phi[ilev]->copyTo(phiInterval, *plotData[ilev], phiInterval); Interval rhsInterval(COMP_POIS_DOF,2*COMP_POIS_DOF-1); a_rhs[ilev]->copyTo(phiInterval, *plotData[ilev], rhsInterval); Interval exInterval(2*COMP_POIS_DOF,3*COMP_POIS_DOF-1); a_exact[ilev]->copyTo(phiInterval, *plotData[ilev], exInterval); // use phi for error const DisjointBoxLayout& dbl = a_grids[ilev]; for (DataIterator dit(dbl); dit.ok(); ++dit) { FArrayBox& exactfab = (*a_exact[ilev])[dit]; FArrayBox& phiFAB = (*a_phi[ilev])[dit]; Box region = exactfab.box(); for (BoxIterator bit(region); bit.ok(); ++bit) { IntVect iv = bit(); for (int i=0;i<COMP_POIS_DOF;i++) phiFAB(iv,i) = phiFAB(iv,i) - exactfab(iv,i); } } // zero error on covered if (ilev!=nLev-1) { const DisjointBoxLayout& dbl = a_grids[ilev]; // zero out fine cover DisjointBoxLayout dblCoarsenedFine; Copier copier; coarsen(dblCoarsenedFine, a_grids[ilev+1], a_refratios[ilev]); // coarsens entire grid copier.define(dblCoarsenedFine, dbl, IntVect::Zero); LevelDataOps<FArrayBox> ops; ops.copyToZero(*a_phi[ilev],copier); } // copy in Interval errInterval(3*COMP_POIS_DOF,4*COMP_POIS_DOF-1); a_phi[ilev]->copyTo(phiInterval, *plotData[ilev], errInterval); // get error norms for (DataIterator dit(dbl); dit.ok(); ++dit) { Box region = dbl[dit]; FArrayBox& phifab = (*a_phi[ilev])[dit]; Real mnorm = phifab.norm(region,0); if (mnorm>a_errNorm[0]) a_errNorm[0] = mnorm; mnorm = phifab.norm(region,1)*D_TERM(dx,*dx,*dx); a_errNorm[1] += mnorm; } } { double error; #ifdef CH_MPI MPI_Allreduce( &a_errNorm[0], &error, 1, MPI_DOUBLE, MPI_MAX, PETSC_COMM_WORLD ); a_errNorm[0] = error; #endif #ifdef CH_MPI MPI_Allreduce( &a_errNorm[1], &error, 1, MPI_DOUBLE, MPI_SUM, PETSC_COMM_WORLD ); a_errNorm[1] = error; #endif } pout() << "\t\t plot |error|_inf=" << a_errNorm[0] << endl; // plot if (true){ CH_TIME("plot"); char suffix[30]; if (a_sub_id>=0) sprintf(suffix, "%dd.%d.hdf5",SpaceDim,a_sub_id); else sprintf(suffix, "%dd.hdf5",SpaceDim); a_fname += suffix; Vector<string> varNames(4*COMP_POIS_DOF); int kk=0; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk] = "phi "; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk] = "rhs "; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk] = "exa "; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk] = "err "; kk=0; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk][3] = '1' + i; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk][3] = '1' + i; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk][3] = '1' + i; for (int i=0; i<COMP_POIS_DOF; ++i,kk++) varNames[kk][3] = '1' + i; Real bogusVal = 1.0; WriteAMRHierarchyHDF5(a_fname, a_grids, plotData, varNames, a_domains[0].domainBox(), a_cdx, bogusVal, bogusVal, a_refratios, nLev); } for (int ilev=0;ilev<nLev;ilev++) { delete plotData[ilev]; } PetscFunctionReturn(0); }
void SPScatterPlotter::plot(QPainter &painter, QRect area) const { plotGrid(painter, area); plotAxis(painter, area, m_xlabel, m_ylable); plotData(painter, area); }
int main (int argc, char **argv) { int dwell; int VHe; /* (V)oltage of (He)lium Target */ float leakageCurrent; int ammeterScale; char analysisFileName[80],backgroundFileName[80],rawDataFileName[80],comments[1024]; char configFileName[]="/home/pi/RbControl/system.cfg"; char buffer[1024]; char dataCollectionFileName[] = "/home/pi/.takingData"; // Variables for getting time information to identify // when we recorded the data time_t rawtime; struct tm * timeinfo; float returnFloat; char* extension; // Setup time variables time(&rawtime); timeinfo=localtime(&rawtime); struct stat st = {0}; // Get parameters. if (argc==6){ VHe=atoi(argv[1]); dwell=atoi(argv[2]); ammeterScale=atof(argv[3]); leakageCurrent=atof(argv[4]); strcpy(comments,argv[5]); strcpy(backgroundFileName,"NONE"); } else { printf("There is one option for using this program: \n\n"); printf("usage '~$ sudo ./polarization <voltage for He target> <dwell> <ammeterScale> <leakageCurrent> <comments_in_double_quotes>'\n"); printf(" (0-120) (1-5)s (assumed neg.) (just mantissa, \n"); printf(" assumed neg.) \n"); return 1; } // Indicate that data is being collected. FILE* dataCollectionFlagFile; dataCollectionFlagFile=fopen(dataCollectionFileName,"w"); if (!dataCollectionFlagFile) { printf("unable to open file \n"); exit(1); } initializeBoard(); initializeUSB1208(); // RUDAMENTARIY ERROR CHECKING if (VHe<0) VHe=0; if (VHe>1023) VHe=1023; // Create Directory for the day strftime(analysisFileName,80,"/home/pi/RbData/%F",timeinfo); if (stat(analysisFileName, &st) == -1){ mkdir(analysisFileName,S_IRWXU | S_IRWXG | S_IRWXO ); sprintf(buffer,"%s/img",analysisFileName); mkdir(analysisFileName,S_IRWXU | S_IRWXG | S_IRWXO ); extension = strstr(buffer,"/img"); strcpy(extension,"/anl"); mkdir(analysisFileName,S_IRWXU | S_IRWXG | S_IRWXO ); } // Create file name. Use format "EX"+$DATE+$TIME+".dat" strftime(rawDataFileName,80,"/home/pi/RbData/%F/POL%F_%H%M%S.dat",timeinfo); strcpy(analysisFileName,rawDataFileName); extension = strstr(analysisFileName,".dat"); strcpy(extension,"analysis.dat"); printf("\n%s\n",analysisFileName); FILE* rawData; // Write the header for the raw data file. rawData=fopen(rawDataFileName,"w"); if (!rawData) { printf("Unable to open file: %s\n", rawDataFileName); exit(1); } fprintf(rawData,"#File\t%s\n",rawDataFileName); fprintf(rawData,"#Comments\t%s\n",comments); printf("Comments:\t%s\n",comments); getIonGauge(&returnFloat); printf("IonGauge %2.2E Torr \n",returnFloat); fprintf(rawData,"#IonGauge(Torr):\t%2.2E\n",returnFloat); getConvectron(GP_N2_CHAN,&returnFloat); printf("CVGauge(N2) %2.2E Torr\n", returnFloat); fprintf(rawData,"#CVGauge(N2)(Torr):\t%2.2E\n", returnFloat); getConvectron(GP_HE_CHAN,&returnFloat); printf("CVGauge(He) %2.2E Torr\n", returnFloat); fprintf(rawData,"#CVGauge(He)(Torr):\t%2.2E\n", returnFloat); returnFloat=-1.0; //getPVCN7500(CN_RESERVE,&returnFloat); fprintf(rawData,"#T_res:\t%f\n",returnFloat); //getSVCN7500(CN_RESERVE,&returnFloat); fprintf(rawData,"#T_res_set:\t%f\n",returnFloat); //getPVCN7500(CN_TARGET,&returnFloat); fprintf(rawData,"#T_trg:\t%f\n",returnFloat); //getSVCN7500(CN_TARGET,&returnFloat); fprintf(rawData,"#T_trg_set:\t%f\n",returnFloat); fprintf(rawData,"#V_he:\t%d\n",VHe); fprintf(rawData,"#LEAKCURR:\t%f\n",leakageCurrent); fprintf(rawData,"#SCALE:\t%d\n",ammeterScale); fprintf(rawData,"#AOUTCONV:\t%2.6f\n",HPCAL); fprintf(rawData,"#REV:\t%d\n",REVOLUTIONS); fprintf(rawData,"#DATAPPR:\t%d\n",DATAPOINTSPERREV); fprintf(rawData,"#STPPERREV:\t%d\n",STEPSPERREV); fprintf(rawData,"#DATPTS:\t%d\n",DATAPOINTS); fprintf(rawData,"#DWELL(s):\t%d\n",dwell); getCommentLineFromFile(configFileName,"#PumpQWPAngle(step):",buffer); fprintf(rawData,"#QWP(STEP):\t%s\n",buffer); fclose(rawData); // Collect raw data getPolarizationData(rawDataFileName, VHe, dwell, leakageCurrent); plotData(rawDataFileName); processFileWithBackground(analysisFileName,backgroundFileName,rawDataFileName,DATAPOINTSPERREV,REVOLUTIONS,1); closeUSB1208(); // Remove the file indicating that we are taking data. fclose(dataCollectionFlagFile); remove(dataCollectionFileName); return 0; }