コード例 #1
0
ファイル: geofeatures.py プロジェクト: WEgeophysics/watex
 def fn(self, features_fn) :
     """ Get the Features file and  seek for pd.Core methods 
     construction."""
     
     if not os.path.isfile(features_fn): 
         raise Wex.WATexError_file_handling(
             'No file detected. Could read `{0}`,`{1}`,`{2}`,'
             '`{3}` and `{4}`files.'.format(*list(self.readFeafmt.keys())))
     
     self.gFname, exT=os.path.splitext(features_fn)
     if exT in self.readFeafmt.keys(): self._fn =exT 
     else: self._fn ='?'
     self._df = self.readFeafmt[exT](features_fn)
     self.gFname = os.path.basename(self.gFname)
コード例 #2
0
ファイル: geofeatures.py プロジェクト: WEgeophysics/watex
 def data_to_numpy(self, data_fn): 
     """
     Method to get datatype and set different features into nympy array
     
     """
     if data_fn is not None : 
         self.erp_data =data_fn 
     
     if not os.path.isfile(self.erp_data): 
         raise Wex.WATexError_file_handling('{} is not a file. '
                                            'Please provide a right file !'
                                            .format(self.erp_data))
     ex_file = os.path.splitext(self.erp_data)[1] 
     if not ex_file in self.dataType.keys(): 
         pass 
コード例 #3
0
def exportdf(df=None,
             refout: str = None,
             to: str = None,
             savepath: str = None,
             modname: str = '_wexported_',
             reset_index: bool = True):
    """ 
    Export dataframe ``df``  to `refout` files. `refout` file can 
    be Excell sheet file or '.json' file. To get more details about 
    the `writef` decorator , see :doc:`watex.utils.decorator.writef`. 
    
    :param refout: 
        Output filename. If not given will be created refering to the 
        exported date. 
        
    :param to: Export type; Can be `.xlsx` , `.csv`, `.json` and else.
       
    :param savepath: 
        Path to save the `refout` filename. If not given
        will be created.
    :param modname: Folder to hold the `refout` file. Change it accordingly.
        
    :returns: 
        - `df_`: new dataframe to be exported. 
        
    """
    if df is None:
        warnings.warn(
            'Once ``df`` arguments in decorator :`class:~decorator.writef`'
            ' is selected. The main type of file ready to be written MUST be '
            'a pd.DataFrame format. If not an error raises. Please refer to '
            ':doc:`~.utils.decorator.writef` for more details.')

        raise Wex.WATexError_file_handling(
            'No dataframe detected. Please provided your dataFrame.')

    df_ = df.copy(deep=True)
    if reset_index is True:
        df_.reset_index(inplace=True)
    if savepath is None:
        savepath = savePath(modname)

    return df_, to, refout, savepath, reset_index
コード例 #4
0
ファイル: geofeatures.py プロジェクト: WEgeophysics/watex
 def from_csv(self, erp_fn):
     """
     Method essentially created to read file from csv , collected 
     horizontal distance value and apparent resistivy values. 
     then send to the class for computation purposes. 
     
     :param erp_fn: path_like string of CSV file 
     :type erp_fn: str 
     
     :return: horizontal distance im meters 
     :rtype: np.array of all data
     """
     if not os.path.isfile(erp_fn):
         raise Wex.WATexError_file_handling('{} is not a file. '
                                            'Please provide a right file !'
                                            .format(erp_fn))
     # with open(erp_fn, 'r') as fcsv: 
     #     csvData = fcsv.readlines()
         
     # retrieve ;locations,  coordinates values for each pk, 
     # horizontal distance in meter and apparent resistivity values 
     pass
コード例 #5
0
ファイル: erp.py プロジェクト: WEgeophysics/watex
    def fn(self, erp_f):
        """ Find the type of data and call pd.Dataframe for reading. 
        numpy array data can get from Dataframe 
        
        :param erp_f: path to :ref:`erp` file
        :type erp_f: str
        
        """
        if erp_f is not None: self.erp_fn = erp_f

        if not os.path.isfile(self.erp_fn):
            raise Wex.WATexError_file_handling(
                'No right file detected ! Please provide the right path.')
        name, exT = os.path.splitext(self.erp_fn)

        if exT in self.dataType.keys():
            self._fn = exT
        else:
            self._fn = '?'

        self._df = self.dataType[exT](self.erp_fn)
        self.data = self._df.to_numpy()
        self._name = os.path.basename(name)