Example usage for java.util HashSet toArray

List of usage examples for java.util HashSet toArray

Introduction

In this page you can find the example usage for java.util HashSet toArray.

Prototype

Object[] toArray();

Source Link

Document

Returns an array containing all of the elements in this set.

Usage

From source file:gov.noaa.pfel.coastwatch.Projects.java

/** 
 * Convert CCHDO (WOCE) bottle .csv files to .nc files.
 * See WHP-Exchange Description (referred to as WED below) 
 * version 4/22/2008 from "Data in 'Exchange' format" 
 * from http://cchdo.ucsd.edu/format.html.
 * WED selected over .nc because //from   w ww  .j ava  2  s  . c o m
 * <br>1) some files available in exchange format and not in .nc, 
 * <br>3) need to process files anyway, to combine date+time.
 * <br>2) .csv is closer to what ERDDAP wants.
 * Created 2011-05-01.
 * 2014-04-08 Changed PSU to 1e-3 (used in cf std names 25)
 */
public static void convertCchdoBottle() throws Exception {
    String inDir = "c:/data/cchdo/botcsv/";
    String outDir = "c:/u00/data/points/cchdoBot/";
    String logFile = "c:/data/cchdo/convertCchdoBottle.log";
    Attributes colInfo = new Attributes(); //colName -> units|type

    String2.setupLog(true, false, logFile, false, 1000000000);
    String2.log("*** Projects.convertCchdoBottle " + Calendar2.getCurrentISODateTimeStringLocalTZ() + "\n"
            + " inDir=" + inDir + "\noutDir=" + outDir + "\nlogFile=" + logFile + "\n"
            + String2.standardHelpAboutMessage());
    long eTime = System.currentTimeMillis();
    HashSet ipts68Columns = new HashSet();
    File2.deleteAllFiles(outDir);

    //for each .csv file
    String[] fileNames = RegexFilenameFilter.list(inDir, ".*\\.csv");
    String2.log("nFiles=" + fileNames.length);
    for (int f = 0; f < fileNames.length; f++) {
        try {
            String2.log("\n#" + f + " " + fileNames[f]);
            String lines[] = String2.readLinesFromFile(inDir + fileNames[f], null, 2);

            //BOTTLE,20030711WHPSIODMB
            //#code : jjward hyd_to_exchange.pl 
            //#original files copied from HTML directory: 20030711
            //#original HYD file: ar24_ahy.txt   Fri Jul 11 12:18:51 2003
            //#original SUM file: ar24_asu.txt   Fri Jul 11 12:34:19 2003
            //EXPOCODE,SECT_ID,STNNBR,CASTNO,SAMPNO,BTLNBR,BTLNBR_FLAG_W,DATE,TIME,LATITUDE,LONGITUDE,DEPTH,CTDPRS,CTDTMP,CTDSAL,SALNTY,SALNTY_FLAG_W,CTDOXY,OXYGEN,OXYGEN_FLAG_W,SILCAT,SILCAT_FLAG_W,NITRAT,NITRAT_FLAG_W,NITRIT,NITRIT_FLAG_W,PHSPHT,PHSPHT_FLAG_W,ALKALI,ALKALI_FLAG_W,CTDRAW,THETA,TCO2,TCO2_FLAG_W
            //,,,,,,,,,,,,DBARS,IPTS-68,PSS-78,PSS-78,,UMOL/KG,UMOL/KG,,UMOL/KG,,UMOL/KG,,UMOL/KG,,UMOL/KG,,UMOL/KG,,,IPTS-68,UMOL/KG,
            //     316N147_2,  AR24,     1,  1,     24, WHF040,2,19961102,1949, 39.1362, -27.3817, 1194,      5.0,  20.7443,  36.1300,  36.1316,2,   -999.0,    225.9,2,     0.49,2,     0.08,2,     0.00,2,     0.05,2,   2362.6,2,  157.5, 20.7433,  2053.1,2

            //extract last chars of first line: division, institute, person (see WED Table 1)            
            //BOTTLE,20081117PRINUNIVRMK
            Table table = new Table();
            Attributes gatts = table.globalAttributes();
            String s = lines[0];
            gatts.add("processed", s.substring(6, 14));
            gatts.add("DivInsWho", s.substring(14)); //DivisionInstituteWho

            //skip # lines  (It's history, but would be lost when files aggregated.)
            int colNamesLine = 1;
            while (lines[colNamesLine].startsWith("#"))
                colNamesLine++;
            //String2.log("  colNamesLine=" + colNamesLine);

            //remove END_DATA and other rows at end
            int endDataLine = lines.length - 1; //index 0.. of endDataLine
            while (!lines[endDataLine].startsWith("END_DATA"))
                endDataLine--;
            String tLines[] = new String[endDataLine];
            System.arraycopy(lines, 0, tLines, 0, endDataLine);
            lines = tLines;

            //read ASCII info into a table
            table.readASCII(inDir + fileNames[f], lines, colNamesLine, colNamesLine + 2, "", null, null, null,
                    null, false); //false=simplify
            int nRows = table.nRows();

            //clean up
            String[] units = String2.split(lines[colNamesLine + 1], ',');
            for (int col = 0; col < units.length; col++) {
                //make column names safe for .nc
                String colName = table.getColumnName(col).toLowerCase();
                colName = String2.replaceAll(colName, '-', '_');
                colName = String2.replaceAll(colName, '+', '_');
                colName = String2.replaceAll(colName, '/', '_');
                if (colName.equals("ammoni")) {
                    String2.log("change colName=ammoni to ammonia");
                    colName = "ammonia";
                } else if (colName.equals("ammoni_flag_w")) {
                    String2.log("change colName=ammoni_flag_w to ammonia_flag_w");
                    colName = "ammonia_flag_w";
                } else if (colName.equals("bltnbr")) {
                    String2.log("change colName=bltnbr to btlnbr");
                    colName = "btlnbr";
                } else if (colName.equals("bltnbr_flag_w")) {
                    String2.log("change colName=bltnbr_flag_w to btlnbr_flag_w");
                    colName = "btlnbr_flag_w";
                } else if (colName.equals("cfc11")) {
                    String2.log("change colName=cfc11 to cfc_11");
                    colName = "cfc_11";
                } else if (colName.equals("ctdfluoro")) {
                    String2.log("change colName=ctdfluoro to ctdfluor");
                    colName = "ctdfluor";
                } else if (colName.equals("ctdfluoro_flag_w")) {
                    String2.log("change colName=ctdfluoro_flag_w to ctdfluor_flag_w");
                    colName = "ctdfluor_flag_w";
                } else if (colName.equals("fco2tmp")) {
                    String2.log("change colName=fco2tmp to fco2_tmp");
                    colName = "fco2_tmp";
                } else if (colName.equals("fco220c")) {
                    String2.log("change colName=fco220c to fco2");
                    colName = "fco2";
                } else if (colName.equals("fco220c_flag_w")) {
                    String2.log("change colName=fco220c_flag_w to fco2_flag_w");
                    colName = "fco2_flag_w";
                } else if (colName.equals("gala")) {
                    String2.log("change colName=gala to gal");
                    colName = "gal";
                } else if (colName.equals("gala_flag_w")) {
                    String2.log("change colName=gala_flag_w to gal_flag_w");
                    colName = "gal_flag_w";
                } else if (colName.equals("gluc")) {
                    String2.log("change colName=gluc to glu");
                    colName = "glu";
                } else if (colName.equals("gluc_flag_w")) {
                    String2.log("change colName=gluc_flag_w to glu_flag_w");
                    colName = "glu_flag_w";
                } else if (colName.equals("neone")) {
                    String2.log("change colName=neone to neoner");
                    colName = "neoner";
                } else if (colName.equals("o18_o16")) {
                    String2.log("change colName=o18_o16 to o18o16");
                    colName = "o18o16";
                } else if (colName.equals("o18_o16_flag_w")) {
                    String2.log("change colName=o18_o16_flag_w to o18o16_flag_w");
                    colName = "o18o16_flag_w";
                } else if (colName.equals("ph_temp")) {
                    String2.log("change colName=ph_temp to ph_tmp");
                    colName = "ph_tmp";
                } else if (colName.equals("phtemp")) {
                    String2.log("change colName=phtemp to ph_tmp");
                    colName = "ph_tmp";
                } else if (colName.equals("poc_flag")) {
                    String2.log("change colName=poc_flag to poc_flag_w");
                    colName = "poc_flag_w";
                } else if (colName.equals("reftemp")) {
                    String2.log("change colName=reftemp to reftmp");
                    colName = "reftmp";
                } else if (colName.equals("reftemp_flag_w")) {
                    String2.log("change colName=reftemp_flag_w to reftmp_flag_w");
                    colName = "reftmp_flag_w";
                } else if (colName.equals("sect_id")) {
                    String2.log("change colName=sect_id to sect");
                    colName = "sect";
                }
                table.setColumnName(col, colName);

                //get units
                String tUnits = units[col];
                if (tUnits.equals("PSU"))
                    tUnits = "1e-3"; //used in CF std names 25
                else
                    tUnits = tUnits.toLowerCase();
                //String2.log("orig colName=" + colName + " tUnits=" + tUnits);

                if (tUnits.equals("%") || tUnits.equals("percnt") || tUnits.equals("percent")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to % (g/100g?)");
                    tUnits = "g/100g";
                } else if (tUnits.equals("dbars") || tUnits.equals("dbr") || tUnits.equals("dba")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to dbar");
                    tUnits = "dbar";
                } else if (tUnits.equals("degc") || tUnits.equals("deg_c") || tUnits.equals("deg-c")
                        || tUnits.equals("dec c") || tUnits.equals("deg c")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to degree_C");
                    tUnits = "degree_C";
                } else if (colName.equals("theta") && (tUnits.equals("deg") || tUnits.equals("dec c"))) { //typo?
                    String2.log("change colName=" + colName + " units=" + tUnits + " to degree_C");
                    tUnits = "degree_C";
                } else if (colName.equals("ph") && (tUnits.equals("sw@25") || tUnits.equals("sw")
                        || tUnits.equals("@25_deg") || tUnits.equals("25_deg"))) {
                    //ph temp should be reported in PH_TMP column
                    String2.log("change colName=" + colName + " units=" + tUnits + " to \"\"");
                    tUnits = "";
                } else if ((tUnits.equals("uatm@20") || tUnits.equals("uatm@4c")) && colName.equals("pco2")) {
                    //pco2 temp should be reported in PCO2_TMP column
                    String2.log("change colName=" + colName + " units=" + tUnits + " to uatm");
                    tUnits = "uatm";
                } else if (tUnits.equals("mille") || tUnits.equals("/mille") || tUnits.equals("\\mille")
                        || tUnits.equals("o/oo")) {
                    //http://www.es.flinders.edu.au/~mattom/IntroOc/lecture03.html says
                    //The symbol o/oo stands for "parts per thousand" or "per mil"; 
                    //a salt content of 3.5% is equivalent to 35 o/oo, 
                    //or 35 grams of salt per kilogram of sea water.
                    //https://en.wikipedia.org/wiki/Per_mil says
                    //A per mil or per mille (also spelled permil, permille,
                    //per mill or promille) (Latin, literally meaning 'for (every) thousand') 
                    //is a tenth of a percent or one part per thousand. 
                    //It is written with the sign .. which looks like a 
                    //percent sign (%) with an extra zero at the end.
                    String2.log("change colName=" + colName + " units=" + tUnits + " to o/oo (g/kg?)");
                    tUnits = "g/kg";
                } else if (colName.equals("c14err") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to o/oo (g/kg?) ?!");
                    tUnits = "g/kg";
                } else if (tUnits.equals("its-90") || tUnits.equals("its90") || tUnits.equals("ipts-90")
                        || tUnits.equals("itst90")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to degree_C");
                    tUnits = "degree_C";
                    table.columnAttributes(col).add("description", "ITS-90");
                } else if (tUnits.equals("ipts-68") || tUnits.equals("ipts68") || tUnits.equals("its-68")
                        || tUnits.equals("r ipts-6")) {
                    //http://www.code10.info/index.php?option=com_content&view=article&id=83:conversions-among-international-temperature-scales&catid=60:temperature&Itemid=83
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to degree_C and multipy by 0.99976");
                    tUnits = "degree_C";
                    table.getColumn(col).scaleAddOffset(0.99976, 1);
                    table.columnAttributes(col).add("description", "Converted from IPTS-68 to ITS-90.");
                    ipts68Columns.add(String2.canonical(colName));
                } else if (tUnits.equals("g umol/k") || tUnits.equals("umol/k") || tUnits.equals("8 umol/k")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to umol/kg");
                    tUnits = "umol/kg";
                }

                //unwanted units
                if ((colName.equals("btlnbr") || colName.equals("btlnbr_flag_w") || colName.equals("castno")
                        || colName.equals("expocode") || colName.equals("sampno") || colName.equals("sect")
                        || colName.equals("stnnbr")) && !tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to \"\"");
                    tUnits = "";
                }

                //missing units
                if (colName.equals("ctdraw") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to dbar ?!");
                    tUnits = "dbar";
                } else if (colName.equals("ctdoxy") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to umol/kg ?!");
                    tUnits = "umol/kg";
                } else if (colName.equals("ctdprs") && (tUnits.equals(""))) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to dbar ?!");
                    tUnits = "dbar";
                } else if (colName.equals("ctdtmp") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to degree_C ?!");
                    tUnits = "degree_C";
                } else if (colName.equals("delher") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to % (g/100g?) ?!");
                    tUnits = "g/100g";
                } else if (colName.equals("depth") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to meters ?!");
                    tUnits = "meters";
                } else if (colName.equals("helier") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to nmol/kg ?!");
                    tUnits = "nmol/kg";
                } else if (colName.equals("neoner") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to nmol/kg ?!");
                    tUnits = "nmol/kg";
                } else if (colName.equals("poc") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to ug/kg ?!");
                    tUnits = "ug/kg";
                } else if (colName.equals("revtmp") && tUnits.equals("")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + "\"\" to degree_C ?!");
                    tUnits = "degree_C";
                }

                //clean up units
                if (colName.equals("depth") && tUnits.equals("m")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to meters");
                    tUnits = "meters";
                } else if (colName.equals("latitude") && (tUnits.equals("") || tUnits.equals("deg"))) {
                    tUnits = "degrees_north";
                } else if (colName.equals("longitude") && (tUnits.equals("") || tUnits.equals("deg"))) {
                    tUnits = "degrees_east";
                } else if (tUnits.equals("pss78") || tUnits.equals("0  pss-7") || tUnits.equals("8  pss-7")
                        || tUnits.equals("iss78") || tUnits.equals("pss-78") || tUnits.equals("c  pss-7")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to 1e-3");
                    tUnits = "1e-3"; //PSU changed to 1e-3 in CF std names 25
                } else if (colName.equals("cfc_12") && tUnits.equals("pm/kg")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to pmol/kg");
                    tUnits = "pmol/kg";
                } else if (tUnits.equals("g pmol/k") || tUnits.equals("pmool/kg")
                        || tUnits.equals("pmol?" + (char) 8 + "/k")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to pmol/kg");
                    tUnits = "pmol/kg";
                } else if (colName.equals("phaeo") && tUnits.equals("mg/m3")) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to ug/l");
                    tUnits = "ug/l"; //  1:1 conversion
                } else if (colName.equals("fluor") && (tUnits.equals("ug/l") || //1:1 conversion
                        tUnits.equals("mg/m^3"))) {
                    String2.log("change colName=" + colName + " units=" + tUnits + " to ug/l");
                    tUnits = "mg/m3"; //  1:1 conversion
                }

                //scale
                if ((tUnits.equals("pmol/kg") || tUnits.equals("pm/kg"))
                        && (colName.equals("cfc_11") || colName.equals("phspht"))) {
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to umol/kg and multiply by 1000000");
                    tUnits = "umol/kg";
                    PrimitiveArray pa = table.getColumn(col);
                    if (!(pa instanceof FloatArray))
                        table.setColumn(col, pa = new FloatArray(pa));
                    pa.scaleAddOffset(1000000, 1);
                } else if ((tUnits.equals("umol/kg") || tUnits.equals("um/kg"))
                        && (colName.equals("barium") || colName.equals("helium") || colName.equals("helier"))) {
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to nmol/kg and multiply by 1000");
                    tUnits = "nmol/kg";
                    PrimitiveArray pa = table.getColumn(col);
                    if (!(pa instanceof FloatArray))
                        table.setColumn(col, pa = new FloatArray(pa));
                    pa.scaleAddOffset(1000, 1);
                } else if ((tUnits.equals("g/100g")) && (colName.equals("c14err"))) {
                    String2.log(
                            "change colName=" + colName + " units=%" + " to o/oo (g/kg?) and multiply by 10");
                    tUnits = "g/kg";
                    PrimitiveArray pa = table.getColumn(col);
                    if (!(pa instanceof FloatArray))
                        table.setColumn(col, pa = new FloatArray(pa));
                    pa.scaleAddOffset(10, 1);
                }

                //set column to NaN
                if ((tUnits.equals("pmol/l") || tUnits.equals("mg/m3"))
                        && (colName.equals("ccl4") || colName.equals("cfc113") || colName.equals("cfc_12"))) {
                    //convert cfc in wrong units to NaNs
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to pmol/kg and set all to -999");
                    tUnits = "pmol/kg";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("e8/l")) && (colName.equals("bact"))) {
                    //convert bact in wrong units to NaNs
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to cells/ml and set all to -999");
                    tUnits = "cells/ml";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("pmol/l") || tUnits.equals("umol/l") || tUnits.equals("ml/l"))
                        && (colName.equals("cfc_11") || colName.equals("ctdoxy") || colName.equals("no2_no3")
                                || colName.equals("oxygen") || colName.equals("phspht")
                                || colName.equals("silcat") || colName.equals("toc"))) {
                    //convert umol/l to NaNs
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to umol/kg and set all to -999");
                    tUnits = "umol/kg";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("umol/kg")) && colName.equals("tritum")) {
                    //convert tritum in umol/kg to NaNs
                    String2.log(
                            "change colName=" + colName + " units=" + tUnits + " to TU and set all to -999");
                    tUnits = "tu";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("ppm") || tUnits.equals("ppm@eq")) && colName.equals("pco2")) {
                    //convert pco2 in ppm to NaNs
                    String2.log(
                            "change colName=" + colName + " units=" + tUnits + " to uatm and set all to -999");
                    tUnits = "uatm";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("ug/l") || tUnits.equals("mg/m3") || tUnits.equals("mg/m**3"))
                        && (colName.equals("chlora") || colName.equals("pphytn"))) {
                    //convert chlora in ug/l to NaNs
                    String2.log(
                            "change colName=" + colName + " units=" + tUnits + " to ug/kg and set all to -999");
                    tUnits = "ug/kg";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("")) && colName.equals("c13err")) {
                    //convert c13err to g/kg and NaNs
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to o/oo (g/kg?) and set all to -999");
                    tUnits = "g/kg";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("")) && colName.equals("phaeo")) {
                    //convert phaeo to ug/l and NaNs
                    String2.log(
                            "change colName=" + colName + " units=" + tUnits + " to ug/l and set all to -999");
                    tUnits = "ug/l";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("")) && colName.equals("revprs")) {
                    //convert revprs to dbar and NaNs
                    String2.log(
                            "change colName=" + colName + " units=" + tUnits + " to dbar and set all to -999");
                    tUnits = "dbar";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("pctmod")) && colName.equals("delhe3")) {
                    //convert delhe3 to g/100g and NaNs
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to % (g/100g?) and set all to -999");
                    tUnits = "g/100g";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("degree_C")) && colName.equals("ctdprs")) {
                    //convert ctdpers to dbar and NaNs
                    String2.log(
                            "change colName=" + colName + " units=" + tUnits + " to dbar and set all to -999");
                    tUnits = "dbar";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if ((tUnits.equals("degree_C") || tUnits.equals("umol/kg"))
                        && (colName.equals("ctdsal") || colName.equals("salnty"))) {
                    //convert ctdpers to dbar and NaNs
                    String2.log(
                            "change colName=" + colName + " units=" + tUnits + " to 1e-3 and set all to -999");
                    tUnits = "1e-3"; //PSU changed to 1e-3 in CF std names 25
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                } else if (tUnits.equals("1e-3") && //?  was PSU
                        colName.equals("ctdtmp")) {
                    //convert ctdtmp to degree_C and NaNs
                    String2.log("change colName=" + colName + " units=" + tUnits
                            + " to degree_C and set all to -999");
                    tUnits = "degree_C";
                    table.setColumn(col, PrimitiveArray.factory(float.class, nRows, "-999"));
                }

                table.columnAttributes(col).add("units", tUnits);

                //diagnostic: print min and max
                //if (colName.equals("btlnbr_flag_w")) {
                //    double stats[] = table.getColumn(col).calculateStats();
                //    String2.log("  btlnbr_flag_w min=" + stats[PrimitiveArray.STATS_MIN] + 
                //        " max=" + stats[PrimitiveArray.STATS_MAX]);
                //}

                //make sure some cols are stored as String
                if ("|expocode|ph_scale|sect|stnnbr|sampno|btlnbr|date|time|"
                        .indexOf("|" + colName + "|") >= 0) {
                    //leave as String
                } else if (colName.equals("castno") || colName.equals("depth")
                        || colName.indexOf("_flag_") > 0) {
                    //convert to short
                    table.setColumn(col, new ShortArray(table.getColumn(col)));
                } else if (colName.equals("id")) {
                    //convert to int
                    table.setColumn(col, new IntArray(table.getColumn(col)));
                } else if (("|14c_doc|alkali|bact|barium|c13err|c14err|ccl4|" + "cfc_11|cfc_12|cfc113|chlora|"
                        + "ctdoxy|ctdprs|ctdraw|ctdsal|ctdtmp|"
                        + "delc13|delc14|delhe3|delsi30|density|doc|dtn|fuco|"
                        + "gala|gluc|helier|helium|man|nitrat|nitrit|no2_no3|o18o16|oxygen|"
                        + "pco2|pco2_tmp|ph|ph_tmp|phaeo|" + "phspht|pphytn|ra_8_6|ra_8_6e|revprs|rham|"
                        + "salnty|silcat|tcarbn|tdn|toc|tritum|").indexOf("|" + colName + "|") >= 0) {
                    //convert to float
                    table.setColumn(col, new FloatArray(table.getColumn(col)));
                } else {
                    //simplify
                    table.simplify(col);
                    PrimitiveArray pa = table.getColumn(col);

                    //convert doubles to floats
                    if (pa instanceof DoubleArray)
                        table.setColumn(col, pa = new FloatArray(pa));
                }

                //add missing_value attribute to non-String columns
                PrimitiveArray pa = table.getColumn(col);
                if (!(pa instanceof StringArray))
                    table.columnAttributes(col).add("missing_value",
                            PrimitiveArray.factory(pa.elementClass(), 1, "-999"));

            }

            //combine date,time
            int dateCol = table.findColumnNumber("date"); //YYYYMMDD
            int timeCol = table.findColumnNumber("time"); //HHMM  (UT)
            Test.ensureTrue(dateCol >= 0, "date column not found.\n" + table.getColumnNamesCSSVString());
            PrimitiveArray datePA = table.getColumn(dateCol);
            StringArray dateTimePA = new StringArray(nRows, false);
            if (timeCol >= 0) {
                //combine date,time
                PrimitiveArray timePA = table.getColumn(timeCol);
                for (int row = 0; row < nRows; row++)
                    dateTimePA.add(datePA.getString(row) + String2.zeroPad(timePA.getString(row), 4));
                table.setColumn(timeCol, dateTimePA);
                table.columnAttributes(timeCol).set("units", "yyyyMMddHHmm");
                table.removeColumn(dateCol); //do last
            } else {
                //convert date to String "time"
                for (int row = 0; row < nRows; row++)
                    dateTimePA.add(datePA.getString(row) + "0000");
                table.setColumn(dateCol, dateTimePA);
                table.setColumnName(dateCol, "time");
                table.columnAttributes(dateCol).set("units", "yyyyMMddHHmm");
            }

            //save all colInfo: Name -> String[] 0=units, 1=type
            for (int col = 0; col < table.nColumns(); col++) {
                String tUnits = table.columnAttributes(col).getString("units");
                String colName = table.getColumnName(col);
                String newInfo = (tUnits == null ? "" : tUnits) + "|"
                        + table.getColumn(col).elementClassString();
                //if (colName.equals("ph_sws_flag_w") && 
                //    fileNames[f].equals("06AQ19960712_hy1.csv")) {
                //    throw new Exception("  col=" + colName + " newInfo=" + newInfo + "\n" +
                //        table.getColumn(col));
                //}
                PrimitiveArray oldInfoPA = colInfo.get(colName);
                //check for different units or type!
                if (oldInfoPA != null) {
                    String oldInfo = oldInfoPA.getString(0);
                    if (!newInfo.equals(oldInfo))
                        throw new RuntimeException("Incompatible: col=" + colName + "\n  oldInfo=" + oldInfo
                                + "  " + String2.annotatedString(oldInfo) + "\n  newInfo=" + newInfo + "  "
                                + String2.annotatedString(newInfo));
                }
                //all is well, set it
                colInfo.set(colName, newInfo);
            }

            //write to .nc file
            table.saveAsFlatNc(outDir + fileNames[f].substring(0, fileNames[f].length() - 4) + ".nc", "row",
                    false);

        } catch (Throwable t) {
            String2.pressEnterToContinue(MustBe.throwableToString(t));
        }
    }

    //write colInfo
    String2.log("Done.  time=" + (System.currentTimeMillis() - eTime) / 1000 + "s");

    String2.log("* columns with PSU should say \"Most values determined by PSS-78.\"");

    String2.log("* columns that had IPTS-68 originally (so metadata should say\n"
            + "\"Some data converted from IPTS-68 to ITS-90 via ITS90 = IPTS68 * 0.99976\"):");
    Object oar[] = ipts68Columns.toArray();
    Arrays.sort(oar);
    String2.log(String2.toNewlineString(oar));

    String2.log("colInfo:");
    String2.log(colInfo.toString());
    String2.returnLoggingToSystemOut();
}