npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jdssat

v4.0.1

Published

Module for reading, writing and processing DSSAT-CSM files

Downloads

36

Readme

jdssat

jdssat is a module for reading, writing and processing DSSAT-CSM files.

jdssat usage

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./node_modules/jdssat/jdssat.js"></script>
</head>
<body>

<h1>This is a Heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Initializing jdssat.js

There are few things that jdssat.js must be aware in order to work with the correct DSSAT version. On the initialization function, the library will look for the platform that is running,it could be darwin (macOS), linux (any linux distro) or win32 (windows). There is a node module https://nodejs.org/api/os.html used by jdssat.js to identify the plaform. Once the platform is retrieved a jdssatconfig.js will be used to load extra OS variables.

Initialize function:

jdssat.initialize()
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script type="text/javascript" src="./node_modules/jdssat/jdssat.js"></script>
</head>
<body>

<h1>This is a Heading</h1>
<p>This is a paragraph.</p>

<script>
  document.addEventListener("DOMContentLoaded", function(event) {
    console.log("DOM fully loaded and parsed");
    jdssat.initialize();
  });
</script>
</body>
</html>

Note that on the example above we are not using any JavaScript framework, such jQuery, Angular, React, Vue, and etc. DSSAT.js play with all of them, it just matter how we initialize it: jQuery style:

<script>
  $(document).ready(function (){
      jdssat.initialize();
  })
</script>

Once jdssat.js is initialized we`ll query one of the configuration objects depending on platform that has being used:

{ "platform": "darwin", "path": "/", "dssatPro": "DSSATPRO.L{dssatVersion}", "tools": "Tools/" }
{ "platform": "win32", "path": "c:/", "dssatPro": "DSSATPRO.V47", "tools": "Tools/" }

With the configuration ready to use, then a global variable will be loaded to keep the global dssat base path, using the latest version installed on user`s machine. For instance:

  • macOS
    • /DSSAT46/
    • /DSSAT47/ latest
  • windows
    • c:/DSSAT46
    • c:/DSSAT47 latest
globalBasePath = "{0}{1}/".format(platform.path, latestVersion);

In case we have to load dssat from a different path, it must be specified on the initialize function:


jdssat.initialize('path')

Reading Experiments

The experiments function receives as input a crop name.

let experiments = jdssat.experiments('Maize');

treatments

Getting Data Files

The getDataFiles function receives as input a crop name and returns an array with all data files name

let dataFiles = jdssat.getDataFiles('Maize');

data files

Reading Treatments

The treatments function receives as input an array containing experiments name.

let experiments = ["IEBR8201.BAX", "MTBO7701.BAX"];
let treatments = jdssat.treatments(experiments);

treatments

Running a simulation

To run a simulation you just have to use runSimulation function and send a crop and what are the experiments as input.

See an example below:

let cropSelected = 'Maize';
let experimentsSelected = [];
let experimentObj = {'experiment': 'BRPI0202.MZX', 'treatment': 'AG9010 - Rainfed', 'trtNo': '1'};
experimentsSelected.push(experimentObj);

jdssat.runSimulation(cropSelected, experimentsSelected);

jdssat.js will create a Batch file at the backgroup and execute a command using a node module https://nodejs.org/api/child_process.html

Creating a Batch File

You also can call createBashFile function without having to run a simulation, it could be useful if you want to run your simulation via command line.

let crop = 'Maize';
let experiments = [];
let experimentObj = {'experiment': 'BRPI0202.MZX', 'treatment': 'AG9010 - Rainfed', 'trtNo': '1'};
experiments.push(experimentObj);

jdssat.createBashFile(crop, experiments);

Note that the annotation is the same as runSimulation function, the only difference is that on the createBashFile function we won`t run anything at the backgroup.

Running Batch File

There is also a possibility to run a batch file stand alone, by running the function below:

let crop = 'Maize';
jdssat.runBatchFile(crop);

This function will create the command and use child process node module to execute the command created.

Reading .OUT files

To read a DSSAT out file, you have to use readOutFile function:

let crop = 'Maize';
let file = 'PlantGro.OUT';

let outFileContent = jdssat.readOutFile(crop, file);

data files

The result of reading a DSSAT OUT file will be an array containing an object for each run. See the object format below:

let obj = {'experiment': 'experiment name', 'run': 'run name': 'values': '[{array of objects with the cde description and its values}]'}

See a sample of Graph built using the result of readOutFile function:

data files

Explicitly reveal public pointers to the private functions

  return {
    initialize: initialize,
    path: path,
    version: version,
    platform: platform,
    tree: tree,
    experiments: experiments,
    experimentDescription: experimentDescription,
    treatments: treatments,
    createBashFile: createBashFile,
    runSimulation: runSimulation,
    outFiles: outFiles,
    readOutFile: readOutFile,
    cde: cde,
    getVariablesFromOutFile: getVariablesFromOutFile,
    openExternalTool: openExternalTool,
    openDssatFolder: openDssatFolder,
    openFileInEditor: openFileInEditor,
    getDataFiles: getDataFiles,
    folders: folders,
    filePreview: filePreview,
    batchCommand: batchCommand,
    runBatchFile: runBatchFile
  }

License

(LICENSE.md)