Saves all of the de-trending information to disk in an `npz` file
        and saves the DVS as a `pdf`.
15136
def save_model(self):
        '''
        

        '''

        # Save the data
        log.info("Saving data to '%s.npz'..." % self.name)
        d = dict(self.__dict__)
        d.pop('_weights', None)
        d.pop('_A', None)
        d.pop('_B', None)
        d.pop('_f', None)
        d.pop('_mK', None)
        d.pop('K', None)
        d.pop('dvs', None)
        d.pop('clobber', None)
        d.pop('clobber_tpf', None)
        d.pop('_mission', None)
        d.pop('debug', None)
        d.pop('transit_model', None)
        d.pop('_transit_model', None)
        np.savez(os.path.join(self.dir, self.name + '.npz'), **d)

        # Save the DVS
        pdf = PdfPages(os.path.join(self.dir, self.name + '.pdf'))
        pdf.savefig(self.dvs.fig)
        pl.close(self.dvs.fig)
        d = pdf.infodict()
        d['Title'] = 'EVEREST: %s de-trending of %s %d' % (
            self.name, self._mission.IDSTRING, self.ID)
        d['Author'] = 'Rodrigo Luger'
        pdf.close()
1227596
def _save_params(self):
        
        self.model.save_params_to_file(self.current_params_fname)
        utils.cleanup_params_files(self.model.output_dir, self.max_params_files_to_keep, self.state.checkpoint,
                                   self.state.best_checkpoint, self.keep_initializations)
817574
def save_snaphot(self):
        
        filename = "%s/%s_%s_%s.dat" % (self.snapshot_path, self.name, self.expiration, self.date)
        with open(filename, 'w') as f:
            f.write(zlib.compress(pickle.dumps(self.current_day_bitarray, protocol=pickle.HIGHEST_PROTOCOL)))
215467
def save_current_nb_as_html(info=False):
    
    assert in_ipynb()

    full_path = get_notebook_name()
    path, filename = os.path.split(full_path)

    wd_save = os.getcwd()
    os.chdir(path)
    cmd = 'jupyter nbconvert --to html "{}"'.format(filename)
    os.system(cmd)
    os.chdir(wd_save)

    if info:
        print("target dir: ", path)
        print("cmd: ", cmd)
        print("working dir: ", wd_save)
601212
def delete_data(self):
        
        self.clean_up()
        tools.delete_dir_rec(self._download_path)
        if self._save_state_file.exists():
            self._save_state_file.unlink()
1013930
def save_as(output_file_path, failure_list=[])
      @pdfreader     = Rjb::import('com.lowagie.text.pdf.PdfReader')
      @pdfcopyfields = Rjb::import('com.lowagie.text.pdf.PdfCopyFields')
      @filestream    = Rjb::import('java.io.FileOutputStream')

      filestream = @filestream.new(output_file_path)
      copy = @pdfcopyfields.new(filestream)
      
      @files_to_merge.each do |f|
        if File.exists?(f)
          begin
            copy.addDocument(@pdfreader.new(f))
          rescue => e
            failure_list << f
            log "PDF::Merger: Invalid PDF: #{f}"            
          end
        else
          failure_list << f
          log "PDF::Merger: File does not exist: #{f}"
        end
      end
      
      if @files_to_merge.size - failure_list.size > 0
        copy.addJavaScript(@js) if @js && !@js.empty?
        copy.close()
        @pdfreader.new(output_file_path).getNumberOfPages
      else
        0
      end
    end
505230
def save_csv(self):
        
        # Sort results so we can start to see patterns right in the raw CSV.
        self.results.sort_values(by=self.column_ids, inplace=True)
        # Gotcha: integers seems to be promoted to float64 because of
        # reindexation. See: https://pandas.pydata.org/pandas-docs/stable
        # /gotchas.html#na-type-promotions
        self.results.reindex(columns=self.column_ids).to_csv(
            self.csv_filepath, index=False)
1231143
def save_to_npy_file(self, parameter_space,
                         result_parsing_function,
                         filename, runs):
        
        np.save(filename, self.get_results_as_numpy_array(
            parameter_space, result_parsing_function, runs=runs))
192329
def save_nff(self, dest, _strategy="auto"):
    
    if _strategy not in ("auto", "write", "mmap"):
        raise TValueError("Invalid parameter _strategy: only 'write' / 'mmap' "
                          "/ 'auto' are allowed")

    dest = os.path.expanduser(dest)
    if not os.path.exists(dest):
        os.makedirs(dest)

    self.materialize()
    mins = self.min().to_list()
    maxs = self.max().to_list()

    metafile = os.path.join(dest, "_meta.nff")
    with _builtin_open(metafile, "w", encoding="utf-8") as out:
        out.write("# NFF2\n")
        out.write("# nrows = %d\n" % self.nrows)
        out.write('filename,stype,meta,colname,min,max\n')
        l = len(str(self.ncols))
        for i in range(self.ncols):
            filename = "c%0*d" % (l, i + 1)
            colname = self.names[i].replace('"', '""')
            stype = self.stypes[i]
            if stype == dt.stype.obj64:
                dtwarn("Column %r of type obj64 was not saved" % self.names[i])
                continue
            smin = _stringify(mins[i][0])
            smax = _stringify(maxs[i][0])
            out.write('%s,%s,,"%s",%s,%s\n'
                      % (filename, stype.code, colname, smin, smax))
            filename = os.path.join(dest, filename)
            core._column_save_to_disk(self, i, filename, _strategy)
546985
def backup_simulation(self):
        
        path = self.new_filename(suffix='_emergency.state')
        self.simulation.saveState(path)
        uses_pbc = self.system.usesPeriodicBoundaryConditions()
        state_kw = dict(getPositions=True, getVelocities=True,
                        getForces=True, enforcePeriodicBox=uses_pbc,
                        getParameters=True, getEnergy=True)
        state = self.simulation.context.getState(**state_kw)
        for reporter in self.simulation.reporters:
            if not isinstance(reporter, app.StateDataReporter):
                reporter.report(self.simulation, state)
1272629
def denoise(data, pon, work_dir):
    
    std_file = os.path.join(work_dir, "%s-crstandardized.tsv" % dd.get_sample_name(data))
    denoise_file = os.path.join(work_dir, "%s-crdenoised.tsv" % dd.get_sample_name(data))
    if not utils.file_exists(std_file):
        with file_transaction(data, std_file, denoise_file) as (tx_std_file, tx_denoise_file):
            params = ["-T", "DenoiseReadCounts",
                      "-I", tz.get_in(["depth", "bins", "target"], data),
                      "--standardized-copy-ratios", tx_std_file,
                      "--denoised-copy-ratios", tx_denoise_file]
            if pon:
                params += ["--count-panel-of-normals", pon]
            else:
                params += ["--annotated-intervals", tz.get_in(["regions", "bins", "gcannotated"], data)]
            _run_with_memory_scaling(params, tx_std_file, data)
    return denoise_file if pon else std_file
221807
def save(path, params = {})
            options =
            {
                delinearize: true,
                recompile: true,
                decrypt: false
            }
            options.update(params)

            if self.frozen? # incompatible flags with frozen doc (signed)
                options[:recompile] =
                options[:rebuild_xrefs] =
                options[:noindent] =
                options[:obfuscate] = false
            end

            if path.respond_to?(:write)
                fd = path
            else
                path = File.expand_path(path)
                fd = File.open(path, 'w').binmode
                close = true
            end

            load_all_objects unless loaded?

            intents_as_pdfa1 if options[:intent] =~ /pdf[\/-]?A1?/i
            self.delinearize! if options[:delinearize] and self.linearized?
            compile(options) if options[:recompile]

            fd.write output(options)
            fd.close if close

            self
        end
460676
def save_mag_to_file(mag, filename, rhofile):
    
    if rhofile:
        # bring data in shape
        null = np.zeros(len(mag))
        if mag.shape[1] == 3:
            null = np.column_stack((null, null, null, null))
        result = np.column_stack((mag, null))

        # save datapoints
        with open(filename, 'w') as fid:
            fid.write('{0}\n'.format(mag.shape[0]))
        with open(filename, 'ab') as fid:
            np.savetxt(fid, np.array(result), fmt='%f')

    else:
        # bring data in shape
        with open('inv/rho00.mag', 'r') as fid:
            coor = np.loadtxt(fid, skiprows=1, usecols=[0, 1])
        # calculated back to log
        if mag.shape[1] == 3:
            logx = [math.log(d, 10) for d in mag[:, 0]]
            logy = [math.log(d, 10) for d in mag[:, 1]]
            logz = [math.log(d, 10) for d in mag[:, 2]]
            mag_log = np.column_stack((logx, logy, logz))
        else:
            mag_log = [math.log(d, 10) for d in mag]
        content = np.column_stack((coor[:, 0], coor[:, 1], mag_log))

        # save datapoints
        with open(filename, 'w') as fid:
            fid.write('{0}\n'.format(content.shape[0]))
        with open(filename, 'ab') as fid:
            np.savetxt(fid, np.array(content), fmt='%f')
397144
def save_data(fpath, data, **kwargs):
    
    ext = splitext(fpath)[1]
    if ext in ['.pickle', '.cPkl', '.pkl']:
        return save_cPkl(fpath, data, **kwargs)
    elif ext in ['.json']:
        return save_json(fpath, data, **kwargs)
    elif ext in ['.hdf5']:
        return save_hdf5(fpath, data, **kwargs)
    elif ext in ['.txt']:
        return save_text(fpath, **kwargs)
    elif HAS_NUMPY and ext in ['.npz', '.npy']:
        return save_numpy(fpath, data, **kwargs)
    else:
        assert False, 'unknown ext=%r for fpath=%r' % (ext, fpath)
334891
def dump(self):
        
        logger.warn('This function is deprecated and replaced by `dump_np_vars`.')

        ret = False

        if self.system.files.no_output:
            # return ``True`` because it did not fail
            return True

        if self.write_lst() and self.write_dat():
            ret = True

        return ret
79202
def save(self, *args, **kwargs):
        """"""
        # open image from pdf
        img = Image(filename=self.file.path + '[0]')

        # make new filename
        filename = os.path.basename(self.file.path).split('.')[:-1]
        if type(filename) == list:
            filename = ''.join(filename)

        # TODO: Would be better to compute this path from the upload_to
        # setting which is already set on the model field
        image_dir = os.path.join(
            django_settings.MEDIA_ROOT, UPLOAD_TO_DIR)
        if not os.path.exists(image_dir):
            os.makedirs(image_dir)

        image_path = os.path.join(
            image_dir, '{}.jpg'.format(filename))
        tmp_image_path = os.path.join(
            image_dir, '{}.tmp.jpg'.format(filename))

        # we remove the old image befor we save because the cover might have
        # changed when we upload a new PDF file - even when that file has the
        # same filename as the old one
        try:
            os.remove(image_path)
        except OSError:
            # file is already gone
            pass
        # and we also remove the thumbnails
        old_files = glob.glob('{}.*'.format(image_path))
        for old_file in old_files:
            try:
                os.remove(old_file)
            except OSError:
                pass

        # save as image under a temporary filename so that we can read it with
        # File()
        img.save(filename=tmp_image_path)
        # attach it to image field
        with open(tmp_image_path, 'r') as f:
            self.image.save('{}.jpg'.format(filename), File(f), save=False)
        super(PDFPluginModel, self).save(*args, **kwargs)

        # remove temp file
        try:
            os.remove(tmp_image_path)
        except OSError:
            pass
281158
def save(self, data, dtype_out_time, dtype_out_vert=False,
             save_files=True, write_to_tar=False):
        """"""
        self._update_data_out(data, dtype_out_time)
        if save_files:
            self._save_files(data, dtype_out_time)
        if write_to_tar and self.proj.tar_direc_out:
            self._write_to_tar(dtype_out_time)
        logging.info('\t{}'.format(self.path_out[dtype_out_time]))