V1_0.java [src/java/m/sq/sci] Revision: default  Date:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package m.sq.sci;

import csip.ModelDataService;
import csip.annotations.*;
import static csip.annotations.State.RELEASED;
import javax.ws.rs.Path;
import static m.sq.Constants.*;

/**
 * SCI service.
 *
 * @author od
 */
@Name("SCI")
@Description("SCI")
@State(RELEASED)
@Path("m/sci/1.0")
public class V1_0 extends ModelDataService {

  static final double SCI_FACTOR = .078740157;
  double water_erosion;
  double water_sci;
  double wind_erosion;
  double wind_sci;
  double sci_total;


  @Override
  protected void preProcess() throws Exception {
    water_erosion = parameter().getDouble(KEY_EROSION_WATER);
    water_sci = parameter().getDouble(KEY_SCI_WATER);
    wind_erosion = parameter().getDouble(KEY_EROSION_WIND);
    wind_sci = parameter().getDouble(KEY_SCI_WIND);
  }


  @Override
  public void doProcess() throws Exception {
    if (water_erosion < wind_erosion) {
      sci_total = wind_sci - SCI_FACTOR * water_erosion;
    } else {
      sci_total = water_sci - SCI_FACTOR * wind_erosion;
    }
  }


  @Override
  protected void postProcess() throws Exception {
    results().put(KEY_SCI_TOTAL, sci_total);
  }

}