Exemple #1
0
        private void btnSaveData_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.InitialDirectory = Directory.GetCurrentDirectory();
            sfd.FileName         = "ResultData.nc";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string theFileName = sfd.FileName;
                NetCDFoperations.SaveDataToFile(imgData.DmSourceData, theFileName, tbStats, true);
            }
        }
Exemple #2
0
        //private void ReadTopoData()
        //{
        //    Dictionary<string, object> dictReadData = NetCDFoperations.ReadDataFromFile(strTopoGeoGridFilename);

        //    dvLatValues = dictReadData[strLatNetCDFVarName] as DenseVector;
        //    dvLatValuesScaledGrid = dictReadData[strLatNetCDFVarName] as DenseVector;
        //    dvLonValues = dictReadData[strLonNetCDFVarName] as DenseVector;
        //    dvLonValuesScaledGrid = dictReadData[strLonNetCDFVarName] as DenseVector;
        //    dmTopoData = dictReadData[strTopoDataNetCDFVarName] as DenseMatrix;
        //    dmTopoDataScaledGrid = dictReadData[strTopoDataNetCDFVarName] as DenseMatrix;
        //    dmTopoDataScaledGrid = ConvertTopoToLog10(dmTopoDataScaledGrid, dmTopoData.Values.Min(),
        //        dmTopoData.Values.Max());


        //    imgGeoImg = new imageConditionAndData(dmTopoDataScaledGrid, null);
        //    imgGeoImg.currentColorScheme = new ColorScheme("");
        //    imgGeoImg.currentColorSchemeRuler = new ColorSchemeRuler(imgGeoImg.currentColorScheme,
        //        dmTopoDataScaledGrid.Values.Min(), dmTopoDataScaledGrid.Values.Max());
        //    imgGeoImg.currentColorSchemeRuler.minValue = dmTopoDataScaledGrid.Values.Min();
        //    imgGeoImg.currentColorSchemeRuler.maxValue = dmTopoDataScaledGrid.Values.Max();
        //    imgGeoImg.currentColorSchemeRuler.imgToRule = imgGeoImg;
        //    imgGeoImg.currentColorSchemeRuler.IsMarginsFixed = false;


        //    DenseMatrix dmTopoDataScaledGridBinary = (DenseMatrix)dmTopoDataScaledGrid.Clone();
        //    dmTopoDataScaledGridBinary.MapInplace(dval => (dval <= 0.0d)?(0.0d):(1.0d));
        //    imgImgTopoEdges = new imageConditionAndData(dmTopoDataScaledGridBinary);
        //    imgImgTopoEdges.setGrayscaleCalculatedColorScheme();
        //    imgImgTopoEdges.currentColorSchemeRuler.minValue = 0.0d;
        //    imgImgTopoEdges.currentColorSchemeRuler.maxValue = 1.0d;
        //    imgImgTopoEdges.currentColorSchemeRuler.IsMarginsFixed = true;
        //    imgImgTopoEdges.currentColorSchemeRuler.imgToRule = imgImgTopoEdges;
        //}
        #endregion // obsolete - TOPO data



        public void ReadGPSFiles(Label lblToShowStatus = null)
        {
            if (listGPSdataLogNetCDFFileNames.Count == 0)
            {
                return;
            }

            if (lTracksData.Count == 0)
            {
                TrackData newTrack = new TrackData();
                newTrack.lineColor = tracksColor;

                lTracksData.Add(newTrack);
            }
            else
            {
                lTracksData.Clear();
                TrackData newTrack = new TrackData();
                lTracksData.Add(newTrack);
            }


            foreach (string GPSdataLogNetCDFfileName in listGPSdataLogNetCDFFileNames)
            {
                if (lblToShowStatus != null)
                {
                    ThreadSafeOperations.SetText(lblToShowStatus, "reading " + GPSdataLogNetCDFfileName, false);
                }

                Dictionary <string, object> dictCurrFileData = NetCDFoperations.ReadDataFromFile(GPSdataLogNetCDFfileName);
                string varNameDateTime = "DateTime";


                List <long>     currFileDateTimeLongTicksList = new List <long>((dictCurrFileData[varNameDateTime] as long[]));
                List <DateTime> currFileDateTimeList          = currFileDateTimeLongTicksList.ConvertAll(longVal => new DateTime(longVal));

                string varNameGPSdata = "GPSdata";

                List <GPSdata> lGPSdataToAdd = GPSdata.OfDenseMatrix(dictCurrFileData[varNameGPSdata] as DenseMatrix);

                TimeSeries <GPSdata> tsCurrFileGPSserie = new TimeSeries <GPSdata>(lGPSdataToAdd, currFileDateTimeList, true);

                tsCurrFileGPSserie.RemoveValues(gpsDatum => ((gpsDatum.lat == 0.0d) && (gpsDatum.lon == 0.0d)));

                lTracksData[0].tsGPSdata.AddSubseriaData(tsCurrFileGPSserie);
            }

            if (lblToShowStatus != null)
            {
                ThreadSafeOperations.SetText(lblToShowStatus, "", false);
            }
        }
Exemple #3
0
 public static string SaveNetCDFdataMatrix(this DenseMatrix dmSource, string fileName, string varName = "dataMatrix")
 {
     if (fileName != "")
     {
         try
         {
             NetCDFoperations.AddDataMatrixToFile(dmSource, fileName, null, true, varName);
             return(fileName);
         }
         catch (Exception)
         {
             return("");
         }
     }
     return("");
 }
        public static Tuple <DateTime, DateTime> GetNetCDFfileTimeStampsRange(string strFileName)
        {
            if (!strFileName.Any())
            {
                return(null);
            }
            if (!File.Exists(strFileName))
            {
                return(null);
            }
            List <DateTime> currFileDateTimeList = null;

            try
            {
                Dictionary <string, object> dictDTdata = NetCDFoperations.ReadDataFromFile(strFileName, new List <string>()
                {
                    "DateTime"
                });
                List <long> currFileDateTimeLongTicksList = new List <long>((dictDTdata["DateTime"] as long[]));
                currFileDateTimeList = currFileDateTimeLongTicksList.ConvertAll(longVal => new DateTime(longVal));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            currFileDateTimeList.Sort();
            if (currFileDateTimeList.Count >= 2)
            {
                return(new Tuple <DateTime, DateTime>(currFileDateTimeList.First(), currFileDateTimeList.Last()));
            }
            else
            {
                return(null);
            }
        }