Skip Navigation Links www.nws.noaa.gov 
NOAA logo - Click to go to the NOAA home page National Weather Service   NWS logo - Click to go to the NWS home page
Climate Prediction Center
 
 

 
About Us
   Our Mission
   Who We Are

Contact Us
   CPC Information
   CPC Web Team

 
HOME > Monitoring_and_Data > Oceanic and Atmospheric Data > Reanalysis: Atmospheric Data > pywgrib2: close(file)
 

pywgrib2: close(file)

Introduction

Pywgrib_s opens a file when you use it, and automatically closes the file when the program ends. You may want to manually close file because

  1. the system limits the number of open files, and you need to close some files before reaching the system limit.
  2. You need to flush the file buffes so a program other than pywgrib2_s can read the file.
  3. pywgrib2_s had an error and the file state needs to be cleaned.
  4. free up memory used to buffer the reads or writes to a no longer used file

Example

>>> pywgrib2_s.mk_inv('a.grb','a.inv',Short=True)
0
>>> pywgrib2_s.close('a.grb')
0
>>> pywgrib2_s.close('not-a-file')
1

Usage

     a=pywgrib2_s.close(file)
         if file is a memory file, the memory file is set to zero length
         if file is open, it closes the file, frees the resources, and returns 0
                closing the file will flush any write buffers
         if file not open, it returns 1

overview back


NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5830 University Research Court
College Park, Maryland 20740
Climate Prediction Center Web Team
Page last modified: July 10, 2014
Disclaimer Privacy Policy