Esempio n. 1
0
        public override LocationTriplet getLocationAsOf(double timeStepFraction)
        {
            LocationTriplet aTrip = new LocationTriplet();

            // inside the array

            aTrip.Altitude  = Altitude.EvaluatePoly(timeStepFraction);
            aTrip.Latitude  = Latitude.EvaluatePoly(timeStepFraction);
            aTrip.Longitude = Longitude.EvaluatePoly(timeStepFraction);

            return(aTrip);
        }
Esempio n. 2
0
        public override double getIntensity(Dictionary <String, Object> results, double lat, double lon, double alt, double height, DateTime asOf)
        {
            cachedEff = null;

            if (timeArray == null)
            {
                timeArray = Location.Select(e => e.Time).ToArray <DateTime>();
            }

            int             index;
            double          fraction;
            LocationTriplet srcLocation;

            if (Utilities.interpolateTimes(timeArray, asOf, out fraction, out index))
            {
                LocationTriplet l1, l2;
                double          secOffset        = (asOf - Location[index].Time).TotalSeconds;
                double          secSpacing       = (Location[index + 1].Time - Location[index].Time).TotalSeconds;
                double          timeStepFraction = secOffset / secSpacing;
                if (Location[index].GetType() == typeof(TimeDependentAnalyticalLocation))
                {
                    // special case
                    srcLocation = Location[index].getLocationAsOf(timeStepFraction);
                }
                else
                {
                    // need to interpolate

                    l1 = Location[index].getLocationAsOf(0);
                    l2 = Location[index + 1].getLocationAsOf(0);

                    srcLocation           = new LocationTriplet();
                    srcLocation.Altitude  = l1.Altitude + (l2.Altitude - l1.Altitude) * timeStepFraction;
                    srcLocation.Latitude  = l1.Latitude + (l2.Latitude - l1.Latitude) * timeStepFraction;
                    srcLocation.Longitude = l1.Longitude + (l2.Longitude - l2.Longitude) * timeStepFraction;
                }
            }
            else
            {
                srcLocation = Location[index].getLocationAsOf(0);
            }



            // calculate distance
            double distance = Utilities.distanceInMeters(lat, srcLocation.Latitude, lon, srcLocation.Longitude, alt, srcLocation.Altitude);

            srcDistance = distance;

            // calculate activity
            double activity   = Utilities.getTemporalFloat(asOf, this.Activity);
            double detPhotons = activity / 4 / Math.PI / distance / distance;

            // calculate efficency
            foreach (InstrumentEfficiency anEff in InstrumentResponse)
            {
                if (results.Keys.Contains(anEff.InstrumentRef))
                {
                    // we care about this instrument
                    double[]   effValues = anEff.getEffAsOf(asOf, height);
                    Instrument anInst    = XSimFieldLibraryImpl.GetInstrumentByID(anEff.InstrumentRef);
                    if (anInst is ScalarInst)
                    {
                        double eff       = effValues[0];
                        double srcValue  = detPhotons * eff;
                        double currValue = (Double)results[anEff.InstrumentRef];
                        currValue += srcValue;
                        results[anEff.InstrumentRef] = currValue;
                    }
                    else
                    {
                        // spectral instrument
                        long[] spectra = (long[])results[anEff.InstrumentRef];
                        for (int i = 0; i < spectra.Length; i++)
                        {
                            long srcValue = (long)Math.Round(detPhotons * effValues[i]);
                            spectra[i] += srcValue;
                        }
                        results[anEff.InstrumentRef] = spectra;
                    }
                }
            }
            return(detPhotons);
        }