/**************************************************************/ /* THEMIS ESA ION AND ELECTRON MOMENTS CDF -> DD netCDF */ /* 04.01.2008 */ /* V 1.1 */ /* Energy in info file */ /* New CDF with ALL modes and new params */ /* 04.01.2008 - 2 files for peir & peer modes */ /**************************************************************/ #include #include #include #include #include #include #include #include #define TimeGap 1800000.0 #define Source "themis@cdpp2" #define MAX_FILE_NAME_LEN 250 // Max. file name length #define MAX_VARS 250 // Max # of VARS in CDF /************************************* Global variables and structures **************************************/ long CDFDims, // Number of dimensions in a CDF file CDFVars, // Number of variables in a CDF file CDFDimSizes[CDF_MAX_DIMS], // Dimension Sizes in a CDF file CDFencoding, // Data encoding CDFmajority, // Variable majority CDFmaxRec, // max Record number CDFAttrs; // number of CDF Attributes struct cdfvar { // CDF variable structure char name[CDF_VAR_NAME_LEN+1]; long num; //variable number long datatype; long numElem; // variable dimensionality long recVariance; // variable rec Variance long dimVariances[CDF_MAX_DIMS]; // # of data values in dimSizes } cdfVar[MAX_VARS]; char mode[4]; int ncID, ncSpID; char ncFile[] = "peif_000000000.nc"; int TimeDimID, TimeLengthID, DataID, Data2ID, FluxDimID;; int TimeDimVector[2], DataDimVector[2], Data2DimVector[2], FluxDimVector[2]; // netCDF Dim vectors size_t Start[2] = {0L,0L}; size_t TimeCount[2] = {1L,TIMELENGTH}; size_t Data1Count[2] = {1L,1L}; size_t DataCount[2] = {1L,3L}; size_t Data2Count[2] = {1L,6L}; size_t FluxCount[2] = {1L,32L}; char Version[]="v01"; char ThemisID[]="tha\0"; char ThemisTime[]="tha_peif_time"; char PAR0[]="tha_peif_delta_time"; char PAR1[]="tha_peif_mode"; char PAR2[]="tha_peif_density"; char PAR3[]="tha_peif_velocity_gse"; char PAR4[]="tha_peif_t3"; // Diagonilized Temperature char PAR5[]="tha_peif_en_eflux"; char PAR6[]="tha_peif_en_eflux_yaxis"; char PAR7[]="tha_peif_avgtemp"; // trace of t3 divided by 3 char PAR8[]="tha_peif_vthermal"; char PAR9[]="tha_peif_sc_pot"; char PAR10[]="tha_peif_sc_current"; char PAR11[]="tha_peif_magt3"; // Temperature in Mag Field frame char PAR12[]="tha_peif_ptens"; // Pressure Tensor DSL char PAR13[]="tha_peif_mftens"; // Momentum Flux Tensor DSL char PAR14[]="tha_peif_flux"; // particle flux char PAR15[]="tha_peif_symm"; // Direction of pressure tensor symmetry in DSL char PAR16[]="tha_peif_symm_ang"; // Angle between Direction of pressure tensor symmetry and B int StartTimeID, StopTimeID; int DeltaTID, DensID, AvTempID, ThVelID, PotID, CurrID, SymAngID; // 1D int MfTempID, TempID, ModeID, VelID, Flux2ID, SymmID; // 2D -> 3 int prTenID, mfTenID; // 2D -> 6 int EnID, FluxID; // 2D -> 32 int TimeID; // Time netCDF variable char StartT[TIMELENGTH]; // Start time from data char StopT[TIMELENGTH]; // Stop time from data /************************** Function prototypes **************************/ void usage(); void cdf_handle_error (CDFstatus); void nc_handle_error (int); void removeFilepath(); void removeCDFext(); void removeVers(); void ncdefine(); /*--------------------------------------------------------------------------*/ void usage() { printf ("\nDescription:\n"); printf (" This program converts a themis CDF file into a netCDF file.\n"); printf ("\n"); printf ("Usage: esa2nc \n"); printf ("\n"); printf ("Example: esa2nc testfile tha peif\n"); printf ("\n"); exit(1); } /*-------------------------------------------------------------------------- * Handles a CDF error. *--------------------------------------------------------------------------*/ void cdf_handle_error(CDFstatus status) { char message[CDF_STATUSTEXT_LEN+1]; CDFerror (status, message); /* Get the appropriate message */ fprintf (stderr, "CDF: %s\n", message); // exit(1); } /*-------------------------------------------------------------------------- * Handles a netCDF error. *--------------------------------------------------------------------------*/ void nc_handle_error(int status) { fprintf(stderr, "%s\n", nc_strerror(status)); exit(1); } /*-------------------------------------------------------------------------- * Remove the filepath from a file name. * * Example: * /home/data/mydata.txt => mydata.txt *--------------------------------------------------------------------------*/ void removeFilepath (char *fileName) { char *ptr; ptr = strrchr(fileName, '/'); // Unix file path separator if (ptr != NULL) { ptr++; strcpy(fileName, ptr); } } /*-------------------------------------------------------------------------- * Decode CDF File Name * *--------------------------------------------------------------------------*/ void removeVers (char *fileName) { char *ptr; char zero = '\0'; int i; for (i = 0; i < 9; i++) { ptr = strchr(fileName, '_'); if (ptr != NULL) { ptr++; strcpy(fileName, ptr); } } ptr = strchr(fileName, '_'); // if (ptr != NULL) { ptr++; strncpy(Version, ptr, 2); } } /*-------------------------------------------------------------------------- * Remove the CDF extention * *--------------------------------------------------------------------------*/ void removeCDFext (char *fileName) { char *ptr; char zero = '\0'; ptr = strchr(fileName, '.'); if (ptr != NULL) strcpy(ptr, &zero); } /*-------------------------------------------------------------------------- * NetCDF File Definition * *--------------------------------------------------------------------------*/ void ncdefine(double Time) { char *s; time_t p; int status; char *STime; /*********************** Create netCDF file *****************************/ memcpy(&(ncFile[0]),&(mode[0]), 4); STime = Double2DD_Time(Time); memcpy(&(ncFile[5]),&(STime[2]), 9); if ((status = nc_create(ncFile, NC_CLOBBER, &ncID)) != NC_NOERR) nc_handle_error(status); /******************netCDF Dimensions *******************************/ nc_def_dim (ncID, "Time", NC_UNLIMITED, &TimeDimID); nc_def_dim (ncID, "TimeLength", TIMELENGTH, &TimeLengthID); nc_def_dim (ncID, "Data",3L, &DataID); nc_def_dim (ncID, "Data2",6L, &Data2ID); nc_def_dim (ncID, "Flux",32L, &FluxDimID); /********************netCDF Variables ******************/ TimeDimVector[0] = TimeDimID; DataDimVector[0] = TimeDimID; Data2DimVector[0] = TimeDimID; TimeDimVector[1] = TimeLengthID; DataDimVector[1] = DataID; FluxDimVector[0] = TimeDimID; FluxDimVector[1] = FluxDimID; Data2DimVector[1] = Data2ID; //ModeID, DensID, VelID, TempID; nc_def_var (ncID, "Time", NC_CHAR, 2, TimeDimVector, &TimeID); nc_def_var (ncID, "delta_time", NC_DOUBLE, 1, &TimeDimID, &DeltaTID); nc_def_var (ncID, "mode", NC_FLOAT, 2, DataDimVector, &ModeID); nc_def_var (ncID, "density", NC_DOUBLE, 1, &TimeDimID, &DensID); nc_def_var (ncID, "avgtemp", NC_DOUBLE, 1, &TimeDimID, &AvTempID); nc_def_var (ncID, "sc_pot", NC_DOUBLE, 1, &TimeDimID, &PotID); nc_def_var (ncID, "sc_current", NC_DOUBLE, 1, &TimeDimID, &CurrID); nc_def_var (ncID, "symm_ang", NC_DOUBLE, 1, &TimeDimID, &SymAngID); nc_def_var (ncID, "vthermal", NC_DOUBLE, 1, &TimeDimID, &ThVelID); nc_def_var (ncID, "velocity_gse", NC_DOUBLE, 2, DataDimVector, &VelID); nc_def_var (ncID, "t3", NC_DOUBLE, 2, DataDimVector, &TempID); nc_def_var (ncID, "magt3", NC_DOUBLE, 2, DataDimVector, &MfTempID); nc_def_var (ncID, "flux", NC_DOUBLE, 2, DataDimVector, &Flux2ID); nc_def_var (ncID, "symm", NC_DOUBLE, 2, DataDimVector, &SymmID); nc_def_var (ncID, "ptens", NC_DOUBLE, 2, Data2DimVector, &prTenID); nc_def_var (ncID, "mftens", NC_DOUBLE, 2, Data2DimVector, &mfTenID); nc_def_var (ncID, "en_eflux", NC_DOUBLE, 2, FluxDimVector, &FluxID); nc_def_var (ncID, "en_eflux_yaxis", NC_FLOAT, 2, FluxDimVector, &EnID); nc_def_var (ncID, "StartTime",NC_CHAR, 1, &TimeLengthID, &StartTimeID); nc_def_var (ncID, "StopTime",NC_CHAR, 1, &TimeLengthID , &StopTimeID); nc_put_att_text(ncID, NC_GLOBAL, "Themis", 3, ThemisID); nc_put_att_text(ncID, NC_GLOBAL, "Source", 12, Source); nc_put_att_text(ncID, DensID, "Units", 5, "cm^-3"); nc_put_att_text(ncID, TempID, "Units", 2, "eV"); nc_put_att_text(ncID, TempID, "Frame", 2, "FA"); nc_put_att_text(ncID, TempID, "Order", 16, "perp1,perp2,para"); nc_put_att_text(ncID, MfTempID, "Units", 2, "eV"); nc_put_att_text(ncID, MfTempID, "Frame", 2, "FA"); nc_put_att_text(ncID, MfTempID, "Order", 16, "perp1,perp2,para"); nc_put_att_text(ncID, AvTempID, "Units", 2, "eV"); nc_put_att_text(ncID, prTenID, "Units", 2, "eV"); nc_put_att_text(ncID, prTenID, "Frame", 3, "DSL"); nc_put_att_text(ncID, prTenID, "Order", 17, "xx,xy,xz,yy,zz,yz"); nc_put_att_text(ncID, mfTenID, "Units", 2, "eV"); nc_put_att_text(ncID, mfTenID, "Frame", 3, "DSL"); nc_put_att_text(ncID, mfTenID, "Order", 17, "xx,xy,xz,yy,zz,yz"); nc_put_att_text(ncID, Flux2ID, "Units", 9, "#/sec/cm2"); nc_put_att_text(ncID, PotID, "Units", 1, "V"); nc_put_att_text(ncID, SymmID, "Frame", 3, "DSL"); nc_put_att_text(ncID, CurrID, "Units", 7, "Unknown"); nc_put_att_text(ncID, SymAngID, "Units", 7, "degrees"); nc_put_att_text(ncID, VelID, "Units", 4, "km/s"); nc_put_att_text(ncID, ThVelID, "Units", 4, "km/s"); nc_put_att_text(ncID, VelID, "Frame", 3, "GSE"); nc_put_att_text(ncID, EnID, "Units", 2, "eV"); nc_put_att_text(ncID, FluxID, "Units", 17, "eV/(cm^2-s-sr-eV)"); time(&p); s = ctime(&p); nc_put_att_text(ncID, NC_GLOBAL, "Created", 24, s); nc_enddef(ncID); nc_put_vara_text(ncID, StartTimeID, &(Start[1]), &(TimeCount[1]), Double2DD_Time(Time)); } /*--------------------------------------------------------------------------*/ int main(int argc, char *argv[]) { long RecStart = 0, RecCount, RecCountF = 1, RecInt = 1, MaxRec; long indices[1] = {0}, counts[1] = {3}, counts2[1] = {6}, countsFlux[1] = {32}, intervals[1] = {1}; long countsE[1] = {1}, indicesF[2]={0,3}, indicesF2[2]={0,6}, indicesFlux[2] = {0, 32}; double *value; float *value_f; size_t numElem; long dimN, varN, par0, par1, par2, par3, par4, par5, par6, par7, par8, par9, par10, par11, par12, par13, par14, par15, par16; CDFstatus cstatus; // CDF status code CDFid id; int i, j, status; char fileName[MAX_FILE_NAME_LEN]; dd_tmstr_t *dtm; int First = 1; double par[3], parr[6], doubleVal, parD[32]; float parF[32], par_f[3], parr_f[6], floatVal; long DayOld; char *UT; char data_set[8]="thx_pexx"; /*-------------------------------- Arguments Decoding ----------------------------------------*/ if (argc <= 3) usage(); // CDF input file name and THEMIS Number not specified else { strcpy(fileName, argv[1]); strncpy(ThemisID,argv[2],3); strncpy(mode,argv[3],4); } /*------------------------------------------ CDF Variables Names Updated according to THEMIS Number -------------*/ memcpy(&(data_set[2]),&(ThemisID[2]),1); memcpy(&(data_set[6]),&(mode[2]),2); memcpy(&(ThemisTime[0]),&(data_set[0]),8); memcpy(&(PAR0[0]),&(data_set[0]),8); memcpy(&(PAR1[0]),&(data_set[0]),8); memcpy(&(PAR2[0]),&(data_set[0]),8); memcpy(&(PAR3[0]),&(data_set[0]),8); memcpy(&(PAR4[0]),&(data_set[0]),8); memcpy(&(PAR5[0]),&(data_set[0]),8); memcpy(&(PAR6[0]),&(data_set[0]),8); memcpy(&(PAR7[0]),&(data_set[0]),8); memcpy(&(PAR8[0]),&(data_set[0]),8); memcpy(&(PAR9[0]),&(data_set[0]),8); memcpy(&(PAR10[0]),&(data_set[0]),8); memcpy(&(PAR11[0]),&(data_set[0]),8); memcpy(&(PAR12[0]),&(data_set[0]),8); memcpy(&(PAR13[0]),&(data_set[0]),8); memcpy(&(PAR14[0]),&(data_set[0]),8); memcpy(&(PAR15[0]),&(data_set[0]),8); memcpy(&(PAR16[0]),&(data_set[0]),8); /*********************** Open CDF file *****************************/ if ((cstatus = CDFopen(fileName, &id)) != CDF_OK) cdf_handle_error(cstatus); printf(" THEMIS %s %s\n", ThemisID, mode); /*********** treat all vars as zVars with eliminated false dimensionality **********/ if ((cstatus = CDFlib(SELECT_, CDF_zMODE_, zMODEon2, NULL_)) != CDF_OK) cdf_handle_error (cstatus); // Remove the file path (/home/data/mydata => mydata) removeFilepath(fileName); // Remove Version Number removeVers(fileName); // Remove .cdf extension removeCDFext(fileName); /************************ Get CDF Data ************************************/ cstatus = CDFlib(GET_, zVAR_NUMBER_, ThemisTime, &varN, NULL_); cstatus = CDFlib( SELECT_, zVAR_, varN, GET_, zVAR_MAXREC_, &MaxRec, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR0, &par0, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR1, &par1, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR2, &par2, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR3, &par3, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR4, &par4, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR5, &par5, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR6, &par6, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR7, &par7, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR8, &par8, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR9, &par9, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR10, &par10, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR11, &par11, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR12, &par12, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR13, &par13, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR14, &par14, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR15, &par15, NULL_); cstatus = CDFlib(GET_, zVAR_NUMBER_, PAR16, &par16, NULL_); RecCount = (long)(MaxRec+1); printf(" Max Rec %d\n", MaxRec); value = (double *)malloc(sizeof(double)* RecCount); if ((cstatus = CDFlib (SELECT_, zVAR_, varN, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_) ) != CDF_OK) cdf_handle_error(cstatus); for (i = 0; i < RecCount; i++) { UT = Double2DD_Time(value[i]); dtm = ReadTime(UT); if (First == 1) { ncdefine(dtm->times); First = 0; } nc_put_vara_text(ncID, TimeID, Start, TimeCount, UT); Start[0]++; } nc_put_vara_text(ncID,StopTimeID, &Start[1], &TimeCount[1], UT); Start[0] = 0L; // deltaT if ((cstatus = CDFlib (SELECT_, zVAR_, par0, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, DeltaTID, value); free(value); value_f = (float *)malloc(sizeof(float)* RecCount * 3); // Mode if ((cstatus = CDFlib (SELECT_, zVAR_, par1, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF, zVAR_DIMCOUNTS_, counts, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value_f, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_float(ncID, ModeID, value_f); free(value_f); value = (double *)malloc(sizeof(double)* RecCount * 3); // peif_velocity_gse if ((cstatus = CDFlib (SELECT_, zVAR_, par3, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF, zVAR_DIMCOUNTS_, counts, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, VelID, value); // temperature if ((cstatus = CDFlib (SELECT_, zVAR_, par4, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF, zVAR_DIMCOUNTS_, counts, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, TempID,value); // temperature regard to B-field if ((cstatus = CDFlib (SELECT_, zVAR_, par11, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF, zVAR_DIMCOUNTS_, counts, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, MfTempID, value); // Flux total if ((cstatus = CDFlib (SELECT_, zVAR_, par14, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF, zVAR_DIMCOUNTS_, counts, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, Flux2ID, value); // symmetry if ((cstatus = CDFlib (SELECT_, zVAR_, par15, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF, zVAR_DIMCOUNTS_, counts, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, SymmID, value); free(value); value = (double *)malloc(sizeof(double)* RecCount * 6); // if ((cstatus = CDFlib (SELECT_, zVAR_, par12, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF2, zVAR_DIMCOUNTS_, counts2, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, prTenID, value); // Pressure Tensor with regard to B-field if ((cstatus = CDFlib (SELECT_, zVAR_, par13, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesF2, zVAR_DIMCOUNTS_, counts2, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, mfTenID, value); free(value); value = (double *)malloc(sizeof(double)* RecCount); // Density if ((cstatus = CDFlib (SELECT_, zVAR_, par2, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, DensID, value); // Average Temperature if ((cstatus = CDFlib (SELECT_, zVAR_, par7, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, AvTempID, value); // Thermal Velocity if ((cstatus = CDFlib (SELECT_, zVAR_, par8, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, ThVelID, value); // Potential if ((cstatus = CDFlib (SELECT_, zVAR_, par9, zVAR_RECNUMBER_, RecStart, zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, PotID, value); // Current /* if ((cstatus = CDFlib (SELECT_, zVAR_, par10, zVAR_RECNUMBER_, RecStart, zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, CurrID, value); */ // Symmery Angle with B if ((cstatus = CDFlib (SELECT_, zVAR_, par16, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indices, zVAR_DIMCOUNTS_, countsE, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, SymAngID, value); free(value); value = (double *)malloc(sizeof(double)* RecCount *32); if ((cstatus = CDFlib (SELECT_, zVAR_, par5, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCount, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesFlux, zVAR_DIMCOUNTS_, countsFlux, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) cdf_handle_error(cstatus); nc_put_var_double(ncID, FluxID, value); /* if ((cstatus = CDFlib (SELECT_, zVAR_, par6, zVAR_RECNUMBER_, RecStart , zVAR_RECCOUNT_, RecCountF, zVAR_RECINTERVAL_, RecInt, zVAR_DIMINDICES_, indicesFlux, zVAR_DIMCOUNTS_, countsFlux, zVAR_DIMINTERVALS_, intervals, GET_, zVAR_HYPERDATA_, parF, NULL_)) != CDF_OK) cdf_handle_error(cstatus); */ /* if (!isnan(parF[0])) nc_put_vara_float(ncID, EnID, Start, FluxCount, parF); else nc_put_vara_float(ncID, EnID, Start, FluxCount, FillValueF); */ // for (j = 0; j < 32; i++) printf(" %f ", parF[j]); // } free(value); /********************Close Files******************/ if ((cstatus = CDFlib(CLOSE_, CDF_, NULL_)) != CDF_OK) cdf_handle_error (cstatus); if ((status = nc_close(ncID)) != NC_NOERR) nc_handle_error(status); }