# Path: polyadcirc/pyADCIRC/basic.py
# class pickleable(object):
#     """
#     Class that makes objects easily pickleable via a dict
#     """
#     def __init__(self):
#         super(pickleable, self).__init__()
# 
#     def __getstate__(self):
#         """
#         :rtype: dict
#         :returns: ``self.__dict__.copy()``
#         """
#         odict = self.__dict__.copy()
#         return odict
# 
#     def __setstate__(self, dict):
#         """
#         :param dict: dict to update
# 
#         ``self.__dict__.update(dict)``
#         """
#         self.__dict__.update(dict)
# 
# Path: polyadcirc/pyGriddata/file_management.py
# def copy(src, dst):
#     """ 
#     If file !exists then copy src into dest
# 
#     :param string src: source file name
#     :param string dst: destination file name
# 
#     """
#     #if os.path.exists(dst+'/'+src) == False:
#     sh.copy(src, dst)
# 
# def mkdir(path):
#     """ 
#     If path !exists then :meth:`os.makedirs`
# 
#     :param string path: path of directory to create
# 
#     """
#     if not os.path.exists(path):
#         os.makedirs(path)


import glob, os, stat, subprocess, shutil 
import scipy.io as sio
import numpy as np
import polyadcirc.pyADCIRC.fort15_management as f15
import polyadcirc.pyGriddata.table_to_mesh_map as tmm
import polyadcirc.pyADCIRC.plotADCIRC as plot
import polyadcirc.pyADCIRC.prep_management as prep
import polyadcirc.pyADCIRC.output as output
import polyadcirc.run_framework.domain as dom
from distutils.spawn import find_executable
from polyadcirc.pyADCIRC.basic import pickleable
from polyadcirc.pyGriddata.file_management import copy, mkdir
                output.get_data_ts(kk, self.rf_dirs[i], self.ts_data, time_obs,
                                   ts_names)
                output.get_data_nts(kk, self.rf_dirs[i], data, self.nts_data,
                                    nts_names)
            # Update and save
            self.update_mdict(mdict)
            self.save(mdict, save_file)
            if num_points <= self.num_of_parallel_runs:
                pass
            elif (k+1)%(num_points/self.num_of_parallel_runs) == 0:
                msg = str(k+1)+" of "+str(num_points)
                print msg+" runs have been completed."

        # save data
        self.update_mdict(mdict)
        self.save(mdict, save_file)

        if cleanup_dirs:
            self.remove_random_field_directories()

        return time_obs, ts_data, nts_data

    def make_plots(self, points, domain, save=True, show=False,
                   bathymetry=False, ext='.eps', ics=2):
        """
        Plots ``mesh``, ``station_locations``, ``basis_functions``,
        ``random_fields``, ``mean_field``, ``station_data``, and
        save in save_dir/figs

        """

# Path: polyadcirc/pyADCIRC/basic.py
# class pickleable(object):
#     """
#     Class that makes objects easily pickleable via a dict
#     """
#     def __init__(self):
#         super(pickleable, self).__init__()
# 
#     def __getstate__(self):
#         """
#         :rtype: dict
#         :returns: ``self.__dict__.copy()``
#         """
#         odict = self.__dict__.copy()
#         return odict
# 
#     def __setstate__(self, dict):
#         """
#         :param dict: dict to update
# 
#         ``self.__dict__.update(dict)``
#         """
#         self.__dict__.update(dict)
# 
# Path: polyadcirc/pyGriddata/file_management.py
# def copy(src, dst):
#     """ 
#     If file !exists then copy src into dest
# 
#     :param string src: source file name
#     :param string dst: destination file name
# 
#     """
#     #if os.path.exists(dst+'/'+src) == False:
#     sh.copy(src, dst)
# 
# def mkdir(path):
#     """ 
#     If path !exists then :meth:`os.makedirs`
# 
#     :param string path: path of directory to create
# 
#     """
#     if not os.path.exists(path):
#         os.makedirs(path)


# Path: polyadcirc/run_framework/random_manningsn.py
import glob, os, stat, subprocess, shutil 
import scipy.io as sio
import numpy as np
import polyadcirc.pyADCIRC.fort15_management as f15
import polyadcirc.pyGriddata.table_to_mesh_map as tmm
import polyadcirc.pyADCIRC.plotADCIRC as plot
import polyadcirc.pyADCIRC.prep_management as prep
import polyadcirc.pyADCIRC.output as output
import polyadcirc.run_framework.domain as dom
from distutils.spawn import find_executable
from polyadcirc.pyADCIRC.basic import pickleable
from polyadcirc.pyGriddata.file_management import copy, mkdir

                output.get_data_ts(kk, self.rf_dirs[i], self.ts_data, time_obs,
                                   ts_names)
                output.get_data_nts(kk, self.rf_dirs[i], data, self.nts_data,
                                    nts_names)
            # Update and save
            self.update_mdict(mdict)
            self.save(mdict, save_file)
            if num_points <= self.num_of_parallel_runs:
                pass
            elif (k+1)%(num_points/self.num_of_parallel_runs) == 0:
                msg = str(k+1)+" of "+str(num_points)
                print msg+" runs have been completed."

        # save data
        self.update_mdict(mdict)
        self.save(mdict, save_file)

        if cleanup_dirs:
            self.remove_random_field_directories()

        return time_obs, ts_data, nts_data

    def make_plots(self, points, domain, save=True, show=False,
                   bathymetry=False, ext='.eps', ics=2):
        """
        Plots ``mesh``, ``station_locations``, ``basis_functions``,
        ``random_fields``, ``mean_field``, ``station_data``, and
        save in save_dir/figs

        """

        mkdir(os.path.join(self.save_dir, 'figs'))