# spacepy.pybats.bats.Mag

class `spacepy.pybats.bats.``Mag`(nlines, time, gmvars=(), ievars=(), *args, **kwargs)

  A container for data from a single BATS-R-US virtual magnetometer. These work just like a typical `spacepy.pybats.PbData` object. Beyond raw magnetometer data, additional values are calculated and stored, including total pertubations (the sum of all global and ionospheric pertubations as measured by the magnetometer). Users will be interested in methods `add_plot()` and `recalc()`.

  Instantiation is best done through :class: spacepy.pybats.MagFile objects, which load and parse organize many virtual magnetometers from a single output file into a single object. However, they can be created manually, though painfully. Users must instantiate by handing the new object the number of lines that will be parsed (rather, the number of data points that will be needed), a time vector, and (optionally) the list of variables coming from the GM and IE module. While the latter two are keyword arguments, at least one should be provided. Next, the arrays whose keys were given by the gmvars and ievars keyword arguments in the instantiation step can either be filled manually or by using the `parse_gmline()` and `parse_ieline()` methods to parse lines of ascii data from a magnetometer output file. Finally, the `recalc()` method should be called to calculate total perturbation.