public void UploadForecastsToGeoServer(Dictionary<DateTime, FileInfo> probabilities)
    {
        if (uploadResultsToGeoserver)
        {
            StartPythonSession();

            Console.WriteLine("Uploading results to the geoserver...\n");

            PyObject upload_files_to_geoserver = uploadToGeoserver.GetAttr("upload_files_to_geoserver");

            PyList files = new PyList();
            List<string> zippedFiles = new List<string>();

            foreach (var s in probabilities.Values)
            {

                //write projection file

                FileInfo prj = new FileInfo(s.FullName.Replace(s.Extension, ".prj"));
                FileInfo tfw = new FileInfo(s.FullName.Replace(s.Extension, ".tfw"));

                File.WriteAllText(prj.FullName, projection.ToUpper());
                string zippedFile = s.FullName.Replace(s.Extension, ".zip");
                zippedFiles.Add(zippedFile);

                using (FileStream fstream = File.Create(zippedFile))
                {

                    using (IWriter writer = WriterFactory.Open(fstream, SharpCompress.Common.ArchiveType.Zip, SharpCompress.Common.CompressionType.None))
                    {
                        writer.Write(s.Name, s.FullName);
                        writer.Write(prj.Name, prj.FullName);
                        writer.Write(tfw.Name, tfw.FullName);
                        writer.Dispose();
                    }

                    fstream.Close();
                    fstream.Dispose();
                }

                files.Append(new PyString(zippedFile));

                //files.Append(new PyString(s.FullName));
            }

            PyObject[] args = new PyObject[]
                {
                    files,
                    new PyString(geoServerURI),
                    new PyString(geoServerRestServiceEndpoint),
                    new PyString(geoServerWorkSpace),
                    new PyString(geoServerUserName),
                    new PyString(GeoServerPassword)
                };

            upload_files_to_geoserver.Invoke(args);
            files.Dispose();
            files = null;

            for (int i = 0; i < args.Length; i++)
            {
                args[i].Dispose();
                args[i] = null;
            }

            foreach (var zipped in zippedFiles)
            {
                if (File.Exists(zipped))
                {
                    try
                    {
                        File.Delete(zipped);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }

            Console.WriteLine("\nFinished uploading results to the geoserver!");

            EndPythonSession();
        }
    }
    private Dictionary<DateTime, List<string>> GetAvailableForecastListFromIrods()
    {
        Dictionary<DateTime, List<string>> forecasts = new Dictionary<DateTime, List<string>>();
        PyObject create_session = iRODSClientModule.GetAttr("create_session");

        PyObject[] sessionArgs = new PyObject[]
                                {
                                    new PyString(iRODShost),
                                    new PyString(iRODSuserName),
                                    new PyString(iRODSpassword),
                                    new PyString(iRODSzone),
                                    new PyInt(iRODSport)
                                };

        PyObject session = create_session.Invoke(sessionArgs);

        PyObject get_collection = iRODSClientModule.GetAttr("get_collection");
        PyObject get_all_data_objects_recursively = iRODSClientModule.GetAttr("get_all_data_objects_recursively");

        PyObject[] args = new PyObject[]
                                {
                                    session,
                                    new PyString(iRODScollection),
                                };

        PyObject headNodeCollection = get_collection.Invoke(args);

        for (int m = 0; m < args.Length; m++)
        {
            PyObject obj = args[m];
            obj.Dispose();
            obj = null;
        }

        args = new PyObject[]{                      headNodeCollection
                                };

        PyObject allFiles = get_all_data_objects_recursively.Invoke(args);

        PyList dataObjects = new PyList(allFiles);

        int value = dataObjects.Length();

        for (int i = 0; i < value; i++)
        {
            PyObject dataObject = dataObjects.GetItem(i);
            string path = dataObject.ToString();

            KeyValuePair<bool, DateTime> dateTime = GetiRODSDataObjectDate(path);

            if (dateTime.Key)
            {
                KeyValuePair<bool, string> ensembleid = GetiRODSDataObjectEnsembleID(path);

                if (ensembleid.Key)
                {
                    if (forecasts.ContainsKey(dateTime.Value))
                    {
                        forecasts[dateTime.Value].Add(path);
                    }
                    else
                    {
                        List<string> newstring = new List<string>();
                        newstring.Add(path);
                        forecasts.Add(dateTime.Value, newstring);
                    }

                }
                else
                {
                    dataObject.ToString();
                }
            }
            else
            {
                dataObject.ToString();
            }

            dataObject.Dispose();
            dataObject = null;
        }

        session.Dispose();
        session = null;
        create_session.Dispose();
        create_session = null;

        for (int m = 0; m < sessionArgs.Length; m++)
        {
            PyObject obj = sessionArgs[m];
            obj.Dispose();
            obj = null;
        }

        get_collection.Dispose();
        get_collection = null;

        get_all_data_objects_recursively.Dispose();
        get_all_data_objects_recursively = null;

        for (int m = 0; m < args.Length; m++)
        {
            PyObject obj = args[m];
            obj.Dispose();
            obj = null;
        }

        headNodeCollection.Dispose();
        headNodeCollection = null;

        allFiles.Dispose();
        allFiles = null;

        dataObjects.Dispose(); dataObjects = null;

        return forecasts;
    }