:py:mod:`gnome.utilities.file_tools.haz_files` ============================================== .. py:module:: gnome.utilities.file_tools.haz_files .. autoapi-nested-parse:: A module that contains various functions for reading and writing assorted HAZMAT file formats. Some of these require the point in polygon code that is in the TAP check_receptors extension module. I should put that in another library. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: gnome.utilities.file_tools.haz_files.BNAData Functions ~~~~~~~~~ .. autoapisummary:: gnome.utilities.file_tools.haz_files.ReadDOGSFile gnome.utilities.file_tools.haz_files.WriteDOGSFiles gnome.utilities.file_tools.haz_files.ReadVerdatFile gnome.utilities.file_tools.haz_files.WriteVerdatFile gnome.utilities.file_tools.haz_files.GetNextBNAPolygon gnome.utilities.file_tools.haz_files.WriteBNA gnome.utilities.file_tools.haz_files.ReadBNA Attributes ~~~~~~~~~~ .. autoapisummary:: gnome.utilities.file_tools.haz_files.FILESCANNER .. py:data:: FILESCANNER :value: False .. py:exception:: FileToolsException Bases: :py:obj:`Exception` The base class for all exceptions in the FileTools module Initialize self. See help(type(self)) for accurate signature. .. py:exception:: BnaError Bases: :py:obj:`FileToolsException` The base class for all exceptions in the FileTools module Initialize self. See help(type(self)) for accurate signature. .. py:class:: BNAData(PointsData=None, Names=None, Types=None, Filename=None) Class to store the full set of data in a BNA file :param PointsData: A sequence of numpy Nx2 arrays of the points (x,y) i.e. long,lat :param Names: A sequence of stings for the names of the polygons :param Types: A sequence of strings for the types of the polygons. .. py:method:: __getitem__(index) .. py:method:: __len__() .. py:method:: __str__() Return str(self). .. py:method:: Save(filename=None) .. py:function:: ReadDOGSFile(filename) .. py:function:: WriteDOGSFiles(filename, Coords, Depths, Units='meters') .. py:function:: ReadVerdatFile(filename) This function reads a DOGS style verdat file The output is zero-index based, rather than 1-index based as it is in the file. ## fixme -- this doesn't keep the units if they are there in the header .. py:function:: WriteVerdatFile(filename, PointData, Boundaries) This function writes a verdata file, of the "DOGS" type. The data passed in must be Verdat legal, and is zero-index based. .. py:function:: GetNextBNAPolygon(f, dtype=np.float64) Utility function that returns the next polygon from a BNA file returns: (points, poly_type, name, sname) where: points: Nx2numpy array of floats with the points poly_type: one of "point", "line", "poly" name: name defined in the BNA sname: secondary name defined in the BNA NOTE: It is the BNA standard to duplicate the first and last points. In that case, the duplicated last point is removed. "holes" in polygons are not supported in this code. See: http://www.softwright.com/faq/support/boundary_file_bna_format.html NOTE: This code doesn't allow extra spaces around the commas in the header line. If there are no commas allowed in the name, it would be easier to simply split on the commas (or march through the line looking for the quotes -- regex?) .. py:function:: WriteBNA(filename, polyset) Writes a BNA file to filename polyset must be a A geometry.polygons.PolygonSet object, with metadata- (poly_type, name, secondary name) (such as returned by ReadBNA) .. py:function:: ReadBNA(filename, polytype='list', dtype=np.float64) Read a bna file. Results are returned as one of: - "list": A list of tuples: (points, poly_type, name, secondary name) - "PolygonSet": A geometry.polygons.PolygonSet object, with metadata- (poly_type, name, secondary name) - "BNADataClass": A BNAData class object -- this may be broken now! The dtype parameter specifies what numpy data type you want the points data in -- it defaults to float (C double)