/// <summary> Deletes MERRA Node data with specified lat/long from DB. </summary>
        public void DeleteMERRANodeDataFromDB(double latitude, double longitude, Continuum thisInst)
        {
            NodeCollection nodeList   = new NodeCollection();
            string         connString = nodeList.GetDB_ConnectionString(thisInst.savedParams.savedFileName);

            try
            {
                using (var context = new Continuum_EDMContainer(connString))
                {
                    var merra_db = from N in context.MERRA_Node_table where N.latitude == latitude & N.longitude == longitude select N;

                    foreach (var N in merra_db)
                    {
                        context.MERRA_Node_table.Remove(N);
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
                return;
            }
        }
        /// <summary> Finds the min/max lat/long of MERRA nodes needed for specified latitude and longitude. Returns coordinates of additional MERRA data needed (if any). </summary>
        public UTM_conversion.Lat_Long[] GetRequiredNewMERRANodeCoords(double latitude, double longitude, Continuum thisInst)
        {
            UTM_conversion.Lat_Long[] newRequiredMERRANodes = new UTM_conversion.Lat_Long[0];
            int numNewReqNodes = 0;

            UTM_conversion.Lat_Long[] theseRequiredNodes = GetRequiredMERRACoords(latitude, longitude);
            UTM_conversion.Lat_Long[] existingNodes      = new UTM_conversion.Lat_Long[0];
            int numExistingNodes = 0;

            // Loop through required nodes and see what additional nodes are needed
            NodeCollection nodeList   = new NodeCollection();
            string         connString = nodeList.GetDB_ConnectionString(thisInst.savedParams.savedFileName);

            using (var context = new Continuum_EDMContainer(connString))
            {
                var theseNodes = from N in context.MERRA_Node_table select N;

                foreach (var N in theseNodes)
                {
                    numExistingNodes++;
                    Array.Resize(ref existingNodes, numExistingNodes);
                    existingNodes[numExistingNodes - 1].latitude  = N.latitude;
                    existingNodes[numExistingNodes - 1].longitude = N.longitude;
                }
            }

            for (int i = 0; i < numMERRA_Nodes; i++)
            {
                bool gotIt = false;
                for (int j = 0; j < numExistingNodes; j++)
                {
                    if (existingNodes[j].latitude == theseRequiredNodes[i].latitude && existingNodes[j].longitude == theseRequiredNodes[i].longitude)
                    {
                        gotIt = true;
                        break;
                    }
                }

                if (gotIt == false)
                {
                    numNewReqNodes++;
                    Array.Resize(ref newRequiredMERRANodes, numNewReqNodes);
                    newRequiredMERRANodes[numNewReqNodes - 1].latitude  = theseRequiredNodes[i].latitude;
                    newRequiredMERRANodes[numNewReqNodes - 1].longitude = theseRequiredNodes[i].longitude;
                }
            }

            return(newRequiredMERRANodes);
        }
        /// <summary> Clears all MERRA data from DB. </summary>
        public void DeleteAllMERRADataFromDB(Continuum thisInst)
        {
            NodeCollection nodeList   = new NodeCollection();
            string         connString = nodeList.GetDB_ConnectionString(thisInst.savedParams.savedFileName);

            try
            {
                using (var ctx = new Continuum_EDMContainer(connString))
                {
                    ctx.Database.ExecuteSqlCommand("DELETE FROM MERRA_Node_table");
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>   Adds the nodes (calculated exposures) to the local SQL database. </summary>
        public void AddNodesDB(Node_table[] theseNodes, string savedFileName)
        {
            if (theseNodes == null)
            {
                return;
            }

            NodeCollection nodeList   = new NodeCollection();
            string         connString = nodeList.GetDB_ConnectionString(savedFileName);

            try
            {
                using (var ctx = new Continuum_EDMContainer(connString))
                {
                    ctx.Node_table.AddRange(theseNodes);
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
                return;
            }
        }