internal TimeIntegratorBasedAverager(IStorageContext storageContext, ITimeAxisAvgProcessing timeIntegrator, IStationLocator stationLocator, double[] lats, double[] lons, string stationsDimName)
        {
            this.timeIntegrator = timeIntegrator;
            this.stationLocator = stationLocator;
            this.dataStorage    = storageContext;
            this.stationsLats   = lats;
            this.stationsLons   = lons;

            IDataStorageDefinition storageDef = storageContext.StorageDefinition;

            //determining dimension order
            var varDimensions = storageContext.StorageDefinition.VariablesDimensions;

            foreach (string dataVarName in varDimensions.Where(a => a.Value.Length == 2).Select(b => b.Key))
            {
                if (varDimensions[dataVarName][0] == stationsDimName)
                {
                    stationsDimNumber.Add(dataVarName, 0);
                    timeDimNumber.Add(dataVarName, 1);
                }
                else
                {
                    stationsDimNumber.Add(dataVarName, 1);
                    timeDimNumber.Add(dataVarName, 0);
                }
            }

            dataRepresentationDictionary = new DataRepresentationDictionary(storageContext.StorageDefinition);
            missingValuesDict            = new MissingValuesDictionary(storageContext.StorageDefinition);
            varTypes = new Dictionary <string, Type>(storageContext.StorageDefinition.VariablesTypes);
        }
 private TimeIntegratorBasedAveragerFactory(IStorageContext context, ITimeAxisAvgProcessing timeIntegrator, IStationLocator stationLocator, double[] stationsLats, double[] stationsLons, string stationDimName)
 {
     this.timeIntegrator = timeIntegrator;
     this.stationLocator = stationLocator;
     this.stationsLats   = stationsLats;
     this.stationsLons   = stationsLons;
     this.stationDimName = stationDimName;
     this.storageContext = context;
 }
        public static async Task <TimeIntegratorBasedAveragerFactory> CreateAsync(IStorageContext storageContext, ITimeAxisAvgProcessing timeIntegrator, IStationLocator stationLocator, string latAxisName = "autodetect", string lonAxisName = "autodetect")
        {
            if (latAxisName == "autodetect")
            {
                latAxisName = IntegratorsFactoryHelpers.AutodetectLatName(storageContext.StorageDefinition);
            }
            if (lonAxisName == "autodetect")
            {
                lonAxisName = IntegratorsFactoryHelpers.AutodetectLonName(storageContext.StorageDefinition);
            }

            //preparing virtual observation axes
            var latsTask = storageContext.GetDataAsync(latAxisName);
            var lonsTask = storageContext.GetDataAsync(lonAxisName);

            var stationsLatsAxis = await latsTask;
            var stationsLonsAxis = await lonsTask;

            int stationsCount = stationsLatsAxis.Length;

            Type latsArrType = stationsLatsAxis.GetType().GetElementType();
            Type lonsArrType = stationsLonsAxis.GetType().GetElementType();

            double[] stationsLats, stationsLons;
            if (latsArrType == typeof(double))
            {
                stationsLats = (double[])stationsLatsAxis;
            }
            else if (latsArrType == typeof(float))
            {
                stationsLats = ((float[])stationsLatsAxis).Select(v => (double)v).ToArray();
            }
            else
            {
                throw new InvalidOperationException("The latitude coordinates of points are neither double nor float type");
            }

            if (lonsArrType == typeof(double))
            {
                stationsLons = (double[])stationsLonsAxis;
            }
            else if (lonsArrType == typeof(float))
            {
                stationsLons = ((float[])stationsLonsAxis).Select(v => (double)v).ToArray();
            }
            else
            {
                throw new InvalidOperationException("The longatude coordinates of points are neither double nor float type");
            }


            return(new TimeIntegratorBasedAveragerFactory(storageContext, timeIntegrator, stationLocator, stationsLats, stationsLons, storageContext.StorageDefinition.VariablesDimensions[latAxisName][0]));
        }