<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_np_dat(self, store_format='csv', delimiter=',', fmt='%.12g'):
 """ Write TDS data stored in `self.np_vars` to the output file Parameters store_format : str dump format in ('csv', 'txt', 'hdf5') delimiter : str delimiter for the `csv` and `txt` format fmt : str output formatting template Returns ------- bool : success flag """

        ret = False
        system = self.system

        # compute the total number of columns, excluding time
        if not system.Recorder.n:
            n_vars = system.dae.m + system.dae.n
            # post-computed power flows include:
            #   bus   - (Pi, Qi)
            #   line  - (Pij, Pji, Qij, Qji, Iij_Real, Iij_Imag, Iji_real, Iji_Imag)
            if system.tds.config.compute_flows:
                n_vars += 2 * system.Bus.n + 8 * system.Line.n + 2 * system.Area.n_combination
            idx = list(range(n_vars))

        else:
            n_vars = len(system.Recorder.varout_idx)
            idx = system.Recorder.varout_idx

        # prepare data
        t_vars_concatenated = self.concat_t_vars_np(vars_idx=idx)

        try:
            os.makedirs(os.path.abspath(os.path.dirname(system.files.dat)), exist_ok=True)
            with open(system.files.dat, self._mode) as f:
                if store_format in ('csv', 'txt'):
                    np.savetxt(f, t_vars_concatenated, fmt=fmt, delimiter=delimiter)
                elif store_format == 'hdf5':
                    pass
                ret = True
                logger.info('TDS data dumped to <{}>'.format(system.files.dat))

        except IOError:
            logger.error('I/O Error while writing the dat file.')

        return ret