Outils pour utilisateurs

Outils du site


sunfluidh:python_read_sunfluidh_files

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
sunfluidh:python_read_sunfluidh_files [2024/02/01 11:54] yannsunfluidh:python_read_sunfluidh_files [2024/04/25 09:40] (Version actuelle) yann
Ligne 14: Ligne 14:
  
 <file txt fct_readsunfluidhdata.py> <file txt fct_readsunfluidhdata.py>
 +
 #!/usr/bin/env python3 #!/usr/bin/env python3
 # -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
Ligne 19: Ligne 20:
 #=========================================================================== #===========================================================================
 #  Author   : Yann Fraigneau, CNRS-LIMSI (yann.fraigneau@limsi.fr) #  Author   : Yann Fraigneau, CNRS-LIMSI (yann.fraigneau@limsi.fr)
-#  date     : July 2020+#  date     : July 2020 - last release : May 2022
 #  comments : Function to read the binary data provided by the code SUNFLUIDH #  comments : Function to read the binary data provided by the code SUNFLUIDH
 # #
Ligne 39: Ligne 40:
 #                   - Velocity components can be easily placed at the cell-centers (as scalar quantities). #                   - Velocity components can be easily placed at the cell-centers (as scalar quantities).
 #                     For that, set flag_center= True (see the example at the end) #                     For that, set flag_center= True (see the example at the end)
 +#
 #=========================================================================== #===========================================================================
  
Ligne 64: Ligne 65:
 #--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
  
 +def _ExistingFileList (dir_name,dset_type) :
 +    """
 +       Check te existence of the access path to dataa, the existence of files related to the type of data
 +       List the present files
 +
 +       Args IN :
 +             dset_type (str) : Type of data ("snapshots","slices,"statistics")
 +             dir_name  (str) : Acces path (where files are stored)
 +
 +       return  : Sorted list of present files
 +
 +    """
 +
 +    #--- Directory exists ?
 +
 +    if os.path.exists(dir_name) :
 +        print("The path acces '{}' is present".format(dir_name))
 +    else :
 +        print("The path acces '{}' is not present".format(dir_name))
 +        print("--- Program stops ---")
 +        exit ()
 +
 +    if dset_type == _lst_filetype[0] :
 +        root="res_*"
 +    elif dset_type == _lst_filetype[1] :
 +        root="slices_*"
 +    elif dset_type == _lst_filetype[2] :
 +        root="rst_*"
 +    else :
 +        print("The selected file type does not exit")
 +        print("Selected a file type among this list : {}".format(_lst_filetype))
 +        print("--- Program stops ---")
 +        exit ()
 +
 +    os.chdir(dir_name)
 +    
 +    return sorted(glob.glob(root))
 +
 +#---------------------------------------------------------------------------------
 +#---------------------------------------------------------------------------------
  
 def _BuildDataAccess (dset_type,dir_name,id_subdom,id_time,slice_id,slice_dir,flag_checkexist=False): def _BuildDataAccess (dset_type,dir_name,id_subdom,id_time,slice_id,slice_dir,flag_checkexist=False):
Ligne 118: Ligne 159:
  
     return data_access,file_name     return data_access,file_name
 + 
 #--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
 #--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
Ligne 233: Ligne 274:
     #---------------------------------------------------------------------------------     #---------------------------------------------------------------------------------
  
-    dt_int32=np.dtype('>i4')+    dt_int32=np.dtype('>i4'
     dt_int64=np.dtype('>i8')     dt_int64=np.dtype('>i8')
     dt_flt32=np.dtype('>f4')     dt_flt32=np.dtype('>f4')
Ligne 249: Ligne 290:
         file_info['number of fields']=data[1]         file_info['number of fields']=data[1]
         #file_info['number of useless elmt']=data[2]         #file_info['number of useless elmt']=data[2]
 +         
         #------------------------------------------------------------------------------------------------         #------------------------------------------------------------------------------------------------
         #--- Extract the data location (useless data at present)         #--- Extract the data location (useless data at present)
Ligne 356: Ligne 397:
  
         #--- Velocity location at the cell-centre         #--- Velocity location at the cell-centre
 +
         if flag_centered_vel and not file_info['centered velocity'] :         if flag_centered_vel and not file_info['centered velocity'] :
             _CenteredVelocity (fieldname=fieldname,field=field)             _CenteredVelocity (fieldname=fieldname,field=field)
Ligne 460: Ligne 502:
  
     Check_Dict (title= "Information collected in dictionnary 'file_info' ", dic=file_info)     Check_Dict (title= "Information collected in dictionnary 'file_info' ", dic=file_info)
 +
  
 </file> </file>
sunfluidh/python_read_sunfluidh_files.txt · Dernière modification : 2024/04/25 09:40 de yann

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki