public async Task <NYCZR8127DaylightEvaluationOutputs> Handler(NYCZR8127DaylightEvaluationInputs args, ILambdaContext context)
        {
            // Preload dependencies (if they exist),
            // so that they are available during model deserialization.

            var sw          = System.Diagnostics.Stopwatch.StartNew();
            var asmLocation = this.GetType().Assembly.Location;
            var asmDir      = Path.GetDirectoryName(asmLocation);

            // Explicitly load the dependencies project, it might have types
            // that aren't used in the function but are necessary for correct
            // deserialization.
            var asmName = Path.GetFileNameWithoutExtension(asmLocation);
            var depPath = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

            if (File.Exists(depPath))
            {
                Console.WriteLine($"Loading dependencies assembly from: {depPath}...");
                Assembly.LoadFrom(depPath);
                Console.WriteLine("Dependencies assembly loaded.");
            }

            // Load all reference assemblies.
            Console.WriteLine($"Loading all referenced assemblies.");
            foreach (var asm in this.GetType().Assembly.GetReferencedAssemblies())
            {
                try
                {
                    Assembly.Load(asm);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed to load {asm.FullName}");
                    Console.WriteLine(e.Message);
                }
            }
            sw.Stop();
            Console.WriteLine($"Time to load assemblies: {sw.Elapsed.TotalSeconds})");

            if (this.store == null)
            {
                this.store = new S3ModelStore <NYCZR8127DaylightEvaluationInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <NYCZR8127DaylightEvaluationInputs, NYCZR8127DaylightEvaluationOutputs>(store, NYCZR8127DaylightEvaluation.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
        /// <summary>
        /// C# in-progress version of this
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A NYCZR8127DaylightEvaluationOutputs instance containing computed results and the model with any new elements.</returns>
        public static NYCZR8127DaylightEvaluationOutputs Execute(Dictionary <string, Model> inputModels, NYCZR8127DaylightEvaluationInputs input)
        {
            var model = new Model();

            inputModels.TryGetValue("Site", out var siteModel);

            if (!inputModels.TryGetValue("Envelope", out var envelopeModel))
            {
                string localFile = "/Users/serenali/Downloads/model 18.json";
                if (File.Exists(localFile))
                {
                    Console.WriteLine("Using local file");
                    string text     = System.IO.File.ReadAllText(localFile);
                    var    envModel = Model.FromJson(text);
                    inputModels["Envelope"] = envModel;
                }
                inputModels.TryGetValue("Envelope", out envelopeModel);
            }

            var siteInput       = getSite(siteModel);
            var envelopes       = getElementsOfType <Envelope>(envelopeModel);
            var rhinoBreps      = getElementsOfType <RhinoBrep>(envelopeModel);
            var rhinoExtrusions = getElementsOfType <RhinoExtrusion>(envelopeModel);
            var meshEnvelopes   = getElementsOfType <MeshElement>(envelopeModel);

            if (siteInput == null)
            {
                throw new ArgumentException("There were no sites found. Please make sure you either meet the dependency of 'Site' or the dependency of 'EnvelopeAndSite."); throw new ArgumentException("BOOO SITE IS NOT FOUND");
            }
            if ((envelopes == null || envelopes.Count < 1) && (meshEnvelopes == null || meshEnvelopes.Count < 1) && (rhinoBreps == null || rhinoBreps.Count < 1) && (rhinoExtrusions == null || rhinoExtrusions.Count < 1))
            {
                throw new ArgumentException("There were no envelopes found. Please make sure you either meet the dependency of 'Envelope' or the dependency of 'EnvelopeAndSite.");
            }

            var site     = siteInput.Perimeter.Bounds();
            var siteRect = Polygon.Rectangle(new Vector3(site.Min.X, site.Min.Y), new Vector3(site.Max.X, site.Max.Y));

            model.AddElement(new ModelCurve(siteRect, name: "Site Bounds Used"));

            GeoUtilities.Model                = model;
            Diagram.Model                     = model;
            SolidAnalysisObject.Model         = model;
            SolidAnalysisObject.SkipSubdivide = input.SkipSubdivide;

            var analysisObjects = SolidAnalysisObject.MakeFromEnvelopes(envelopes);

            foreach (var analysisObject in SolidAnalysisObject.MakeFromMeshElements(meshEnvelopes))
            {
                analysisObjects.Add(analysisObject);
            }

            foreach (var analysisObject in SolidAnalysisObject.MakeFromRhinoBreps(rhinoBreps))
            {
                analysisObjects.Add(analysisObject);
            }

            foreach (var analysisObject in SolidAnalysisObject.MakeFromRhinoExtrusions(rhinoExtrusions))
            {
                analysisObjects.Add(analysisObject);
            }

            // Only applicable for E Midtown
            List <SolidAnalysisObject> analysisObjectsForBlockage = input.QualifyForEastMidtownSubdistrict ? getEastMidtownEnvelopes(envelopes, rhinoBreps, rhinoExtrusions, meshEnvelopes, model, input.DebugVisualization) : null;

            var margin             = 20;
            var vsIndex            = 0;
            var verticalOffsetBase = Settings.ChartHeight + margin;

            var streetScores             = new List <double>();
            var streetLengths            = 0.0;
            var streetScoresTimesLengths = 0.0;

            if (input.VantageStreets.Count < 1)
            {
                throw new Exception("Please provide at least one vantage street");
            }

            foreach (var vantageStreet in input.VantageStreets)
            {
                var matchingOverride = input.Overrides?.VantageStreets.FirstOrDefault(x => x.Identity.Name == vantageStreet.Name);

                var color = DebugUtilities.random.NextColor();
                var vantageStreetMaterial = new Material($"Vantage Street {vantageStreet.Name}", color)
                {
                    EdgeDisplaySettings = new EdgeDisplaySettings {
                        LineWidth = 2
                    }
                };
                var vantagePointMaterial = new Material($"Vantage Point on {vantageStreet.Name}", new Color(color.Red, color.Green, color.Blue, 0.15))
                {
                    EdgeDisplaySettings = new EdgeDisplaySettings {
                        LineWidth = 2
                    }
                };
                var outputVantageStreet = VantageElementUtils.CreateVantageStreet(siteRect, vantageStreet, out var vantagePoints, matchingOverride, model);
                outputVantageStreet.Material = vantageStreetMaterial;

                int vpIndex = 0;

                foreach (var vp in vantagePoints)
                {
                    var transform = new Transform(new Vector3(90.0 + vpIndex * 200.0, site.Max.Y + margin + verticalOffsetBase * vsIndex));

                    var name = $"{vantageStreet.Name}: VP {vpIndex + 1}";

                    vp.Diagram.Draw(name, model, analysisObjects, input, input.DebugVisualization, analysisObjectsForBlockage: analysisObjectsForBlockage);

                    var outputVp = new NYCDaylightEvaluationVantagePoint(
                        vp.Diagram.DaylightBlockage,
                        vp.Diagram.UnblockedDaylightCredit,
                        vp.Diagram.ProfilePenalty,
                        vp.Diagram.AvailableDaylight,
                        vp.Diagram.DaylightRemaining,
                        vp.Diagram.DaylightScore,
                        outputVantageStreet,
                        material: vantagePointMaterial,
                        name: name
                        );
                    outputVp.SetViz(vp.GetViewCone());
                    model.AddElement(outputVp);

                    var vpHelper = vp.GetVisualizationHelpers();
                    vpHelper.Name = $"{outputVp.Name} Helper";
                    // vpHelper.AdditionalProperties["Target"] = outputVp.Id; // makes interface too messy
                    model.AddElement(vpHelper);

                    vpIndex += 1;
                }

                var sumScores           = vantagePoints.Aggregate(0.0, (sum, vp) => sum + vp.Diagram.DaylightScore);
                var vantageStreetScore  = sumScores / vantagePoints.Count;
                var vantageStreetLength = outputVantageStreet.FrontLotLine.Length();

                streetScores.Add(vantageStreetScore);
                streetLengths            += vantageStreetLength;
                streetScoresTimesLengths += vantageStreetScore * vantageStreetLength;

                outputVantageStreet.Score = vantageStreetScore;
                model.AddElement(outputVantageStreet);

                vsIndex += 1;
            }

            var lowestStreetScore = new List <double>(streetScores).OrderBy(score => score).ToList()[0];
            var overallScore      = streetScoresTimesLengths / streetLengths;

            var pass = true;

            if (lowestStreetScore < 66)
            {
                pass = false;
            }
            if (!input.QualifyForEastMidtownSubdistrict && overallScore < 75)
            {
                pass = false;
            }
            if (input.QualifyForEastMidtownSubdistrict && overallScore < 66)
            {
                pass = false;
            }

            Console.WriteLine($"LOWEST SCORE: {lowestStreetScore}");
            Console.WriteLine($"TOTAL SCORE: {overallScore}");

            var output = new NYCZR8127DaylightEvaluationOutputs(lowestStreetScore, overallScore, pass ? "PASS" : "FAIL");

            output.Model = model;

            return(output);
        }