protected float Sample(ProfileableResource resource, Vector3 worldPos, float noiseScalar)
        {
            float abundance = 0f;

            AbundanceRequest req = new AbundanceRequest();
            double           alt;
            double           lat;
            double           lon;

            part.vessel.mainBody.GetLatLonAlt(new Vector3d(worldPos.x, worldPos.y, worldPos.z), out lat, out lon, out alt);

            req.BodyId       = FlightGlobals.GetBodyIndex(part.vessel.mainBody);
            req.ResourceName = resource.resourceName;
            req.Latitude     = lat;
            req.Altitude     = alt;
            req.Longitude    = lon;

            // Sample atmo
            req.ResourceType = HarvestTypes.Atmospheric;
            abundance       += ResourceMap.Instance.GetAbundance(req);
            if (resource.useAtmo)
            {
                abundance = abundance * (float)part.vessel.mainBody.GetPressure(alt);
            }

            // Sample exo
            req.ResourceType = HarvestTypes.Exospheric;
            abundance        = abundance + ResourceMap.Instance.GetAbundance(req);
            //Utils.Log(String.Format("[ModuleProfilingScanner]: Sampling position {0}, geocentric alt {1}, lat {2} lon {3}\n Noise: {4} Result: {5}", worldPos.ToString(), alt, lat, lon, noiseScalar, abundance));
            abundance = abundance + noiseScalar * UnityEngine.Random.Range(-1.0f, 1.0f);

            return(Mathf.Clamp(abundance, 0f, 10000f));
        }
        // Profiles a specific resource
        protected ResourceProfile TakeResourceProfile(ProfileableResource resource)
        {
            float distance = 0f;

            Dictionary <float, float> samples = new Dictionary <float, float>();
            float scanInterval = Mathf.Clamp((ScanRange) / ScanCount, 0.5f, 500000f);

            //Utils.Log(String.Format("[ModuleProfilingScanner]: Scan Interval {0}", scanInterval));

            while (distance <= ScanRange)
            {
                float   fracDist = Mathf.Clamp01(distance / MaximumRange);
                float   noise    = fracDist * resource.noiseMax + resource.noiseMin;
                Vector3 pos      = part.partTransform.position + part.partTransform.up.normalized * distance * 1000f;
                samples.Add(distance * 1000f, Sample(resource, pos, noise));

                distance = distance + scanInterval;
            }
            return(new ResourceProfile(resource.resourceName, resource.readoutMax, samples));
        }