Package: bas-apres
apresThis project enables ApRES .dat files to be read, rewritten, and converted.The apres packageThe apres package contains a number of classes for working with ApRES .dat files.TheApRESBurstclass manages reading/writing a single burst block (the textual header and the binary data) from/to an opened ApRES .dat file.TheApRESFileclass is a context manager for ApRES .dat files.  The class wraps theApRESBurstclass and can read a variable number of burst blocks from a file (i.e. a single burst file or a timeseries file).  It also contains methods for subsetting an ApRES file, and for converting the file to netCDF4.InstallThe package can be installed from PyPI (note the package distribution name):$pipinstallbas-apresSimple utility scriptsThe package contains a number of scripts for converting from/to netCDF, plotting the data etc.  When installing the package (e.g., viapip install) then these scripts are available as commands and added to thePATH.  So for instance, you can just callapres_to_nc.  If running the scripts from acloneof the source code repository, then they need to be run as modules, e.g.python -m apres.apres_to_nc.apres_to_nc.pyThis script converts an ApRES .dat file to netCDF4.  The default output netCDF filename has the same name as the input .dat file, but with a .nc file suffix.  Optionally an alternative output netCDF filename can be explicitly given.python3-mapres.apres_to_ncfilename.dat[outfile.nc]The conversion is a straightforward mapping, in that each burst becomes a netCDF4 group, where the header lines become group attributes, and the data are stored as aNSubBurstsxN_ADC_SAMPLES2D data array.nc_to_apres.pyThis script converts a previously converted netCDF4 file back to the original ApRES .dat file.  The default output ApRES .dat filename has the same name as the input netCDF file, but with a .dat file suffix.  Optionally an alternative output ApRES filename can be explicitly given.python3-mapres.nc_to_apresinfile.nc[outfile.dat]The conversion is a straightforward reversal of the original conversion.  For the newer ApRES .dat file format version, this should be identical to the original file.  For the older ApRES .dat file format version, there will likely be small differences in the whitespace in the textual header.  Ignoring these insignificant changes in whitespace (e.g.diff -awB orig.dat reconstructed.dat), the files will be identical.plot_apres.pyThis script will plot theN_ADC_SAMPLESvsNSubBurstsas a radargram, for each burst in the file (or group for converted netCDF files).  If theAverageheader item > 0 (and so each subburst has been aggregated), then the script will instead plot the first subburst as a single trace.  The file can be either an ApRES .dat file, or a converted netCDF file.python3-mapres.plot_apres[-h][-r|-t][-gGRIDGRID][-cCONTRAST][-mCMAP]filename.{dat,nc}plotApRESdata,eitherfroma.datfile,oraconvertednetCDFfile

positionalarguments:filenamefilename

optionalarguments:-h,--helpshowthishelpmessageandexit-r,--radargramplotaradargram-t,--tracesplotindividualtraces-gGRIDGRID,--gridGRIDGRIDplotthefirstnrowsxncolstraces-cCONTRAST,--contrastCONTRASTcontrastfortheradargram-mCMAP,--cmapCMAPcolourmapfortheradargram

Examples

PlotthegivenApRES.datfileasaradargram:

python3-mapres.plot_apresfilename.dat

PlotthegivenconvertednetCDFfileasaradargram:

python3-mapres.plot_apresfilename.nc

PlotthegivenApRESfileasaradargram,increasingthecontrast:

python3-mapres.plot_apres-c10filename.dat

Sameasabove,butwithablue-white-redcolourmap:

python3-mapres.plot_apres-c10-mbwrfilename.dat

PlotthefirsttracefromthegivenApRESfile:

python3-mapres.plot_apres-tfilename.dat

Plotthefirst6traces,ina3x2grid:

python3-mapres.plot_apres-t-g32filename.datread_apres.pyThis script will read the given ApRES .dat file, and for each burst, print the results of parsing the header, such as the dimensions of the data array, and the parsed header dictionary.  It will alsoheadthe data section (by default the first 10 samples of the first 10 subbursts), to give an initial simple look at the data.The script's primary purpose is as a simple example of how to use theApRESFileclass to read an ApRES .dat file.python3-mapres.read_apresfilename.datwrite_apres.pyThis script will read the given input ApRES .dat file, and for each burst, write the header and data to the given output ApRES .dat file.  Optionally a subset of bursts can be written out, specified as the firstburstsbursts of the input file.  In addition a subset of each burst can be written out, specified as the firstsubburstssubbursts, and the firstsamplesADC samples of these subbursts.  Ifbursts,subburstsandsamplesare not specified, then the output file is identical to the input file.The script's primary purpose is as a simple example of how to use theApRESFileclass to rewrite an ApRES .dat file.python3-mapres.write_apres[-bBURSTS][-uSUBBURSTS][-sSAMPLES]infile.datoutfile.dat