Package org.rascalmpl.ast

Examples of org.rascalmpl.ast.Field$Index


    return String.valueOf(characters, index++, len);
  }

  @Override
  public Index getIndex(int bookmark) {
    return new Index(bookmark, index);
  }
View Full Code Here


    int nFields = selectedFields.length;
    int fieldIndices[] = new int[nFields];
    Type baseType = this.getType();
   
    for (int i = 0; i < nFields; i++) {
      Field f = selectedFields[i];
      if (f.isIndex()) {
        fieldIndices[i] = ((IInteger) f.getFieldIndex()
            .interpret(this.ctx.getEvaluator()).getValue()).intValue();
      } else {
        String fieldName = org.rascalmpl.interpreter.utils.Names
            .name(f.getFieldName());
        try {
          fieldIndices[i] = baseType.getFieldIndex(fieldName);
        } catch (UndeclaredFieldException e) {
          throw new UndeclaredField(fieldName, baseType,
              ctx.getCurrentAST());
View Full Code Here

      int nFields = selectedFields.length;
      int fieldIndices[] = new int[nFields];
      Type baseType = this.getType();
     
      for (int i = 0; i < nFields; i++) {
        Field f = selectedFields[i];
        if (f.isIndex()) {
          fieldIndices[i] = ((IInteger) f.getFieldIndex()
              .interpret(this.ctx.getEvaluator()).getValue()).intValue();
        } else {
          String fieldName = org.rascalmpl.interpreter.utils.Names
              .name(f.getFieldName());
          try {
            fieldIndices[i] = baseType.getFieldIndex(fieldName);
          } catch (UndeclaredFieldException e) {
            throw new UndeclaredField(fieldName, baseType,
                ctx.getCurrentAST());
View Full Code Here

    int nFields = selectedFields.length;
    int fieldIndices[] = new int[nFields];
    Type baseType = this.getType();
   
    for (int i = 0; i < nFields; i++) {
      Field f = selectedFields[i];
      if (f.isIndex()) {
        fieldIndices[i] = ((IInteger) f.getFieldIndex()
            .interpret(this.ctx.getEvaluator()).getValue()).intValue();
      } else {
        String fieldName = org.rascalmpl.interpreter.utils.Names
            .name(f.getFieldName());
        try {
          fieldIndices[i] = baseType.getFieldIndex(fieldName);
        } catch (UndeclaredFieldException e) {
          throw new UndeclaredField(fieldName, baseType,
              ctx.getCurrentAST());
View Full Code Here

      int nFields = selectedFields.length;
      int fieldIndices[] = new int[nFields];
      Type baseType = this.getType();
     
      for (int i = 0; i < nFields; i++) {
        Field f = selectedFields[i];
        if (f.isIndex()) {
          fieldIndices[i] = ((IInteger) f.getFieldIndex()
              .interpret(this.ctx.getEvaluator()).getValue()).intValue();
        } else {
          String fieldName = org.rascalmpl.interpreter.utils.Names
              .name(f.getFieldName());
          try {
            fieldIndices[i] = baseType.getFieldIndex(fieldName);
          } catch (UndeclaredFieldException e) {
            throw new UndeclaredField(fieldName, baseType,
                ctx.getCurrentAST());
View Full Code Here

    int ni = shape[0];
    int nj = shape[1];
    int nk = shape[2];

    array = new ArrayDouble.D3(ni, nj, nk);
    Index index = array.getIndex();

    for (int i = 0; i < ni; i++) {
      for (int j = 0; j < nj; j++) {
        for (int k = 0; k < nk; k++) {
          index.set(i, j, k);
          double d = pertArray.getDouble(index)
              + baseArray.getDouble(index);
          if (isZStag) {
            d = d / 9.81//convert geopotential to height
          }
View Full Code Here

      IndexChunker.printl(" dataStrides=", dataStrides);
      IndexChunker.printa(" wantStride=", resultStrides);
      System.out.println(" indexChunks=" + Index.computeSize(shape));
    }
    dataIndex = new IndexLong(shape, dataStrides);
    resultIndex = new Index(shape, resultStrides);

    if (debugDetail) {
      System.out.println(" dataIndex="+ dataIndex.toString());
      System.out.println(" resultIndex="+ resultIndex.toStringDebug());
    }
View Full Code Here

    Array data = v.read();
    int[] shape = data.getShape();
    assert shape[0] == 1000;
    assert shape[1] == 20;

    Index ima = data.getIndex();
    for (int i = 0; i < 1000; i++)
      for (int j = 0; j < 20; j++) {
        int val = data.getInt(ima.set(i, j));
        assert val == i + j : val + " != " + (i + j);
      }

  }
View Full Code Here

        Array dataArray =
            Array.factory(v2.getDataType().getPrimitiveClassType(),
                          section.getShape());

        Index dataIndex = dataArray.getIndex();

        if (varname.equals("latitude") || varname.equals("longitude")) {
            double[][] pixel = new double[2][1];
            double[][] latLon;
            double[][][] latLonValues =
                new double[geoXRange.length()][geoYRange.length()][2];

            // Use Range object, which calculates requested i, j
            // values and incorporates stride
            for (int i = 0; i < geoXRange.length(); i++) {
                for (int j = 0; j < geoYRange.length(); j++) {
                    pixel[0][0] = (double) geoXRange.element(i);
                    pixel[1][0] = (double) geoYRange.element(j);
                    latLon      = nav.toLatLon(pixel);

                    if (varname.equals("lat")) {
                        dataArray.setFloat(dataIndex.set(j, i),
                                           (float) (latLon[0][0]));
                    } else {
                        dataArray.setFloat(dataIndex.set(j, i),
                                           (float) (latLon[1][0]));
                    }
                }
            }
        }

        if (varname.equals("image")) {
            try {
                int[][] pixelData = new int[1][1];
                if (bandRange != null) {
                    for (int k = 0; k < bandRange.length(); k++) {
                        int bandIndex = bandRange.element(k) + 1// band numbers in McIDAS are 1 based
                        for (int j = 0; j < geoYRange.length(); j++) {
                            for (int i = 0; i < geoXRange.length(); i++) {
                                pixelData = af.getData(geoYRange.element(j),
                                        geoXRange.element(i), 1, 1,
                                        bandIndex);
                                dataArray.setInt(dataIndex.set(0, k, j, i),
                                        (pixelData[0][0]));
                            }
                        }
                    }

                } else {
                    for (int j = 0; j < geoYRange.length(); j++) {
                        for (int i = 0; i < geoXRange.length(); i++) {
                            pixelData = af.getData(geoYRange.element(j),
                                    geoXRange.element(i), 1, 1);
                            dataArray.setInt(dataIndex.set(0, j, i),
                                             (pixelData[0][0]));
                        }
                    }

                }
View Full Code Here

                    var=varList.get(ix);
                    if ((var.getShortName()).equals("numGates")) { numGates=var; break}
                }
            }
            ArrayInt.D1 gatesArr=(ArrayInt.D1) Array.factory(DataType.INT, numGates.getShape());
            Index gatesIndex=gatesArr.getIndex();
           
            for (int i=0; i<number_sweeps; i++) {
                List rlist = sgp[i];
                for (int jj=0; jj<num_rays; jj++) { rtemp[jj]=(Ray)rlist.get(jj); } //ray[i][jj]; }
                ngates=rtemp[0].getBins();
                gatesArr.setInt(gatesIndex.set(i), ngates);
            }

            for (int i=0; i<number_sweeps; i++) {
                distanceR[i].setCachedData(distArr[i], false);
                time[i].setCachedData(timeArr[i], false);
View Full Code Here

TOP

Related Classes of org.rascalmpl.ast.Field$Index

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.