_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q175200 | NOWRadiosp.readData | test | public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException {
// subset
Object data;
Array outputData;
byte[] vdata = null;
NOWRadheader.Vinfo vinfo;
ByteBuffer bos;
List<Range> ranges = section.getRanges();
vinfo = (NOWRadheader.Vinfo) v2.getSPobject();
vdata = headerParser.getData((int) vinfo.hoff);
bos = ByteBuffer.wrap(vdata);
data = readOneScanData(bos, vinfo, v2.getShortName());
outputData = Array.factory(v2.getDataType(), v2.getShape(), data);
outputData = outputData.flip(1);
// outputData = outputData.flip(2);
return (outputData.sectionNoReduce(ranges).copy());
// return outputData;
} | java | {
"resource": ""
} |
q175201 | NOWRadiosp.readOneRowData | test | public byte[] readOneRowData(byte[] ddata, int rLen, int xt) throws IOException, InvalidRangeException {
int run;
byte[] bdata = new byte[xt];
int nbin = 0;
int total = 0;
for (run = 0; run < rLen; run++) {
int drun = DataType.unsignedByteToShort(ddata[run]) >> 4;
byte dcode1 = (byte) (DataType.unsignedByteToShort(ddata[run]) & 0Xf);
for (int i = 0; i < drun; i++) {
bdata[nbin++] = dcode1;
total++;
}
}
if (total < xt) {
for (run = total; run < xt; run++) {
bdata[run] = 0;
}
}
return bdata;
} | java | {
"resource": ""
} |
q175202 | NcDDS.createFromDataset | test | private void createFromDataset(NetcdfDataset ncd) {
// get coordinate variables, disjunct from variables
for (CoordinateAxis axis : ncd.getCoordinateAxes()) {
coordvars.put(axis.getShortName(), axis);
}
// dup the variable set
ddsvars = new ArrayList<>(50);
// collect grid array variables and set of coordinate variables used in grids
for (Variable v : ncd.getVariables()) {
if (coordvars.containsKey(v.getShortName())) continue; // skip coordinate variables
ddsvars.add(v);
boolean isgridarray = (v.getRank() > 1) && (v.getDataType() != DataType.STRUCTURE) && (v.getParentStructure() == null);
if (!isgridarray) continue;
List<Dimension> dimset = v.getDimensions();
int rank = dimset.size();
for (int i = 0; isgridarray && i < rank; i++) {
Dimension dim = dimset.get(i);
if (dim.getShortName() == null)
isgridarray = false;
else {
Variable gv = coordvars.get(dim.getShortName());
if (gv == null)
isgridarray = false;
}
}
if (isgridarray) {
gridarrays.put(v.getFullName(), v);
for (Dimension dim : dimset) {
Variable gv = coordvars.get(dim.getShortName());
if (gv != null)
used.put(gv.getFullName(), gv);
}
}
}
// Create the set of coordinates
for (Variable cv : ncd.getCoordinateAxes()) {
BaseType bt = createVariable(ncd, cv);
addVariable(bt);
}
// Create the set of variables
for (Variable cv : ddsvars) {
BaseType bt = createVariable(ncd, cv);
addVariable(bt);
}
} | java | {
"resource": ""
} |
q175203 | NcDDS.createVariable | test | private BaseType createVariable(NetcdfFile ncfile, Variable v) {
BaseType bt;
if (v.getRank() == 0) // scalar
bt = createScalarVariable(ncfile, v);
else if (v.getDataType() == DataType.CHAR) {
if (v.getRank() > 1)
bt = new NcSDCharArray(v);
else
bt = new NcSDString(v);
} else if (v.getDataType() == DataType.STRING) {
if (v.getRank() == 0)
bt = new NcSDString(v);
else
bt = new NcSDArray(v, new NcSDString(v));
} else // non-char multidim array
bt = createArray(ncfile, v);
return bt;
} | java | {
"resource": ""
} |
q175204 | NavigatedPanel.fireMapAreaEvent | test | void fireMapAreaEvent() {
if (debugZoom)
System.out.println("NP.fireMapAreaEvent ");
// decide if we need a new Projection: for LatLonProjection only
if (project.isLatLon()) {
LatLonProjection llproj = (LatLonProjection) project;
ProjectionRect box = getMapArea();
double center = llproj.getCenterLon();
double lonBeg = LatLonPointImpl.lonNormal(box.getMinX(), center);
double lonEnd = lonBeg + box.getMaxX() - box.getMinX();
boolean showShift = Debug.isSet("projection/LatLonShift") || debugNewProjection;
if (showShift) System.out.println("projection/LatLonShift: min,max = "+ box.getMinX()+" "+
box.getMaxX()+" beg,end= "+lonBeg+" "+lonEnd+ " center = "+center);
if ( (lonBeg < center-180) || (lonEnd > center+180)) { // got to do it
double wx0 = box.getX() + box.getWidth()/2;
llproj.setCenterLon( wx0); // shift cylinder seam
double newWx0 = llproj.getCenterLon(); // normalize wx0 to [-180,180]
setWorldCenterX(newWx0); // tell navigation panel to shift
if (showShift)
System.out.println("projection/LatLonShift: shift center to "+wx0+"->"+newWx0);
// send projection event instead of map area event
lmProject.sendEvent( new NewProjectionEvent(this, llproj));
return;
}
}
// send new map area event
lmMapArea.sendEvent( new NewMapAreaEvent( this, getMapArea()));
} | java | {
"resource": ""
} |
q175205 | NavigatedPanel.setMapArea | test | public void setMapArea(ProjectionRect ma) {
if (debugBB) System.out.println("NP.setMapArea "+ ma);
navigate.setMapArea(ma);
} | java | {
"resource": ""
} |
q175206 | NavigatedPanel.setMapArea | test | public void setMapArea(LatLonRect llbb) {
if (debugBB) System.out.println("NP.setMapArea (ll) "+ llbb);
navigate.setMapArea( project.latLonToProjBB(llbb));
} | java | {
"resource": ""
} |
q175207 | NavigatedPanel.setLatLonCenterMapArea | test | public void setLatLonCenterMapArea( double lat, double lon) {
ProjectionPoint center = project.latLonToProj(lat, lon);
ProjectionRect ma = getMapArea();
ma.setX( center.getX() - ma.getWidth()/2);
ma.setY( center.getY() - ma.getHeight()/2);
setMapArea(ma);
} | java | {
"resource": ""
} |
q175208 | NavigatedPanel.setProjectionImpl | test | public void setProjectionImpl( ProjectionImpl p) {
// transfer selection region to new coord system
if (geoSelection != null) {
LatLonRect geoLL = project.projToLatLonBB(geoSelection);
setGeoSelection( p.latLonToProjBB( geoLL));
}
// switch projections
project = p;
navigate.setMapArea(project.getDefaultMapArea());
if (Debug.isSet("projection/set") || debugNewProjection)
System.out.println("projection/set NP="+ project);
// transfer reference point to new coord system
if (hasReference) {
refWorld.setLocation(project.latLonToProj( refLatLon));
}
} | java | {
"resource": ""
} |
q175209 | NavigatedPanel.addActionsToMenu | test | public void addActionsToMenu (JMenu menu) {
BAMutil.addActionToMenu( menu, zoomIn);
BAMutil.addActionToMenu( menu, zoomOut);
BAMutil.addActionToMenu( menu, zoomBack);
BAMutil.addActionToMenu( menu, zoomDefault);
menu.addSeparator();
BAMutil.addActionToMenu( menu, moveUp);
BAMutil.addActionToMenu( menu, moveDown);
BAMutil.addActionToMenu( menu, moveRight);
BAMutil.addActionToMenu( menu, moveLeft);
menu.addSeparator();
BAMutil.addActionToMenu( menu, setReferenceAction);
} | java | {
"resource": ""
} |
q175210 | NavigatedPanel.redrawLater | test | private void redrawLater(int delay) {
boolean already = (redrawTimer != null) && (redrawTimer.isRunning());
if (debugThread) System.out.println( "redrawLater isRunning= "+ already);
if (already)
return;
// initialize Timer the first time
if (redrawTimer == null) {
redrawTimer = new javax.swing.Timer(0, new ActionListener() {
public void actionPerformed(ActionEvent e) {
drawG();
redrawTimer.stop(); // one-shot timer
}
});
}
// start the timer running
redrawTimer.setDelay(delay);
redrawTimer.start();
} | java | {
"resource": ""
} |
q175211 | NavigatedPanel.newScreenSize | test | private void newScreenSize(Rectangle b) {
boolean sameSize = (b.width == myBounds.width) && (b.height == myBounds.height);
if (debugBounds) System.out.println( "NavigatedPanel newScreenSize old= "+myBounds);
if (sameSize && (b.x == myBounds.x) && (b.y == myBounds.y))
return;
myBounds.setBounds(b);
if (sameSize)
return;
if (debugBounds) System.out.println( " newBounds = " +b);
// create new buffer the size of the window
//if (bImage != null)
// bImage.dispose();
if ((b.width > 0) && (b.height > 0)) {
bImage = new BufferedImage(b.width, b.height, BufferedImage.TYPE_INT_RGB); // why RGB ?
} else { // why not device dependent?
bImage = null;
}
navigate.setScreenSize(b.width, b.height);
} | java | {
"resource": ""
} |
q175212 | DatasetTreeView.setSelected | test | public void setSelected( VariableIF v ) {
if (v == null) { return; }
// construct chain of variables
final List<VariableIF> vchain = new ArrayList<>();
vchain.add( v);
VariableIF vp = v;
while (vp.isMemberOfStructure()) {
vp = vp.getParentStructure();
vchain.add( 0, vp); // reverse
}
// construct chain of groups
final List<Group> gchain = new ArrayList<>();
Group gp = vp.getParentGroup();
gchain.add( gp);
while (gp.getParentGroup() != null) {
gp = gp.getParentGroup();
gchain.add( 0, gp); // reverse
}
final List<Object> pathList = new ArrayList<>();
// start at root, work down through the nested groups, if any
GroupNode gnode = (GroupNode) model.getRoot();
pathList.add( gnode);
Group parentGroup = gchain.get(0); // always the root group
for (int i=1; i < gchain.size(); i++) {
parentGroup = gchain.get(i);
gnode = gnode.findNestedGroup( parentGroup);
assert gnode != null;
pathList.add( gnode);
}
vp = vchain.get(0);
VariableNode vnode = gnode.findNestedVariable( vp);
if (vnode == null) { return; } // not found
pathList.add( vnode);
// now work down through the structure members, if any
for (int i=1; i < vchain.size(); i++) {
vp = vchain.get(i);
vnode = vnode.findNestedVariable( vp);
if (vnode == null) { return; } // not found
pathList.add(vnode);
}
// convert to TreePath, and select it
final Object[] paths = pathList.toArray();
final TreePath treePath = new TreePath(paths);
tree.setSelectionPath( treePath);
tree.scrollPathToVisible( treePath);
} | java | {
"resource": ""
} |
q175213 | CDMArrayAtomic.getDouble | test | public double getDouble(int offset)
{
DapVariable d4var = (DapVariable) getTemplate();
long[] dimsizes = DapUtil.getDimSizes(d4var.getDimensions());
return getDouble(DapUtil.offsetToIndex(offset, dimsizes));
} | java | {
"resource": ""
} |
q175214 | CDMArrayAtomic.getDouble | test | protected double getDouble(dap4.core.util.Index idx)
{
assert data.getScheme() == Scheme.ATOMIC;
try {
Object value = data.read(idx);
value = Convert.convert(DapType.FLOAT64, this.basetype, value);
return (Double) java.lang.reflect.Array.get(value, 0);
} catch (IOException ioe) {
throw new IndexOutOfBoundsException(ioe.getMessage());
}
} | java | {
"resource": ""
} |
q175215 | CDMArrayAtomic.getObject | test | protected Object getObject(dap4.core.util.Index idx)
{
assert data.getScheme() == Scheme.ATOMIC;
try {
Object value = data.read(idx);
value = java.lang.reflect.Array.get(value, 0);
return value;
} catch (IOException ioe) {
throw new IndexOutOfBoundsException(ioe.getMessage());
}
} | java | {
"resource": ""
} |
q175216 | Giniheader.gini_GetSectorID | test | String gini_GetSectorID(int ent_id) {
String name;
switch (ent_id) {
case 0:
name = "Northern Hemisphere Composite";
break;
case 1:
name = "East CONUS";
break;
case 2:
name = "West CONUS";
break;
case 3:
name = "Alaska Regional";
break;
case 4:
name = "Alaska National";
break;
case 5:
name = "Hawaii Regional";
break;
case 6:
name = "Hawaii National";
break;
case 7:
name = "Puerto Rico Regional";
break;
case 8:
name = "Puerto Rico National";
break;
case 9:
name = "Supernational";
break;
case 10:
name = "NH Composite - Meteosat/GOES E/ GOES W/GMS";
break;
case 11:
name = "Central CONUS";
break;
case 12:
name = "East Floater";
break;
case 13:
name = "West Floater";
break;
case 14:
name = "Central Floater";
break;
case 15:
name = "Polar Floater";
break;
default:
name = "Unknown-ID";
}
return name;
} | java | {
"resource": ""
} |
q175217 | Giniheader.readScaledInt | test | private double readScaledInt(ByteBuffer buf) {
// Get the first two bytes
short s1 = buf.getShort();
// And the last one as unsigned
short s2 = DataType.unsignedByteToShort(buf.get());
// Get the sign bit, converting from 0 or 2 to +/- 1.
int posneg = 1 - ((s1 & 0x8000) >> 14);
// Combine the first two bytes (without sign bit) with the last byte.
// Multiply by proper factor for +/-
int nn = (((s1 & 0x7FFF) << 8) | s2) * posneg;
return (double) nn / 10000.0;
} | java | {
"resource": ""
} |
q175218 | CoordinateTransform.findParameterIgnoreCase | test | public Parameter findParameterIgnoreCase(String name) {
for (Parameter a : params) {
if (name.equalsIgnoreCase(a.getName()))
return a;
}
return null;
} | java | {
"resource": ""
} |
q175219 | MultiOdometer.hasNext | test | @Override
public boolean
hasNext()
{
if(this.current >= odomset.size())
return false;
Odometer ocurrent = odomset.get(this.current);
if(ocurrent.hasNext())
return true;
// Try to move to next odometer
this.current++;
return hasNext();
} | java | {
"resource": ""
} |
q175220 | GradsDataDescriptorFile.swapByteOrder | test | private void swapByteOrder() {
// NB: we are setting bigEndian to be opposite the system arch
String arch = System.getProperty("os.arch");
if (arch.equals("x86") || // Windows, Linux
arch.equals("arm") || // Window CE
arch.equals("x86_64") || // Windows64, Mac OS-X
arch.equals("amd64") || // Linux64?
arch.equals("alpha")) { // Utrix, VAX, DECOS
bigEndian = true;
} else {
bigEndian = false;
}
} | java | {
"resource": ""
} |
q175221 | GradsDataDescriptorFile.getTimeStepsPerFile | test | public int[] getTimeStepsPerFile(String filename) {
if (chsubs != null) {
for (Chsub ch : chsubs) {
if (filename.contains(ch.subString)) {
return new int[]{ch.numTimes, ch.startTimeIndex};
}
}
}
return new int[]{timeStepsPerFile, 0};
} | java | {
"resource": ""
} |
q175222 | GradsDataDescriptorFile.getFileName | test | public String getFileName(int eIndex, int tIndex) {
String dataFilePath = dataFile;
if ((getTemplateType() == ENS_TEMPLATE) || (getTemplateType() == ENS_TIME_TEMPLATE)) {
dataFilePath = getEnsembleDimension().replaceFileTemplate(dataFilePath, eIndex);
}
dataFilePath = getTimeDimension().replaceFileTemplate(dataFilePath, tIndex);
if ((chsubs != null) && (dataFilePath.contains(CHSUB_TEMPLATE_ID))) {
for (Chsub ch : chsubs) {
if ((tIndex >= ch.startTimeIndex) && (tIndex <= ch.endTimeIndex)) {
dataFilePath = dataFilePath.replace(CHSUB_TEMPLATE_ID, ch.subString);
break;
}
}
}
return getFullPath(dataFilePath);
} | java | {
"resource": ""
} |
q175223 | GradsDataDescriptorFile.getFileNames | test | private List<String> getFileNames() throws IOException {
if (fileNames == null) {
fileNames = new ArrayList<>();
timeStepsPerFile = tDim.getSize();
if (!isTemplate()) { // single file
fileNames.add(getFullPath(getDataFile()));
} else { // figure out template type
long start = System.currentTimeMillis();
List<String> fileSet = new ArrayList<>();
String template = getDataFile();
if (GradsTimeDimension.hasTimeTemplate(template)) {
if (template.contains(GradsEnsembleDimension.ENS_TEMPLATE_ID)) {
templateType = ENS_TIME_TEMPLATE;
} else {
templateType = TIME_TEMPLATE;
}
} else { // not time - either ens or chsub
if (template.contains(GradsEnsembleDimension.ENS_TEMPLATE_ID)) {
templateType = ENS_TEMPLATE;
} else {
templateType = TIME_TEMPLATE;
}
}
if (templateType == ENS_TEMPLATE) {
for (int e = 0; e < eDim.getSize(); e++) {
fileSet.add(
getFullPath(
eDim.replaceFileTemplate(template, e)));
}
} else if ((templateType == TIME_TEMPLATE)
|| (templateType == ENS_TIME_TEMPLATE)) {
int numens = (templateType == TIME_TEMPLATE)
? 1
: eDim.getSize();
for (int t = 0; t < tDim.getSize(); t++) {
for (int e = 0; e < numens; e++) {
String file = getFileName(e, t);
if (!fileSet.contains(file)) {
fileSet.add(file);
}
}
}
// this'll be a bogus number if chsub was used
timeStepsPerFile = tDim.getSize()
/ (fileSet.size() / numens);
}
//System.out.println("Time to generate file list = "
// + (System.currentTimeMillis() - start));
fileNames.addAll(fileSet);
}
//long start2 = System.currentTimeMillis();
// now make sure they exist
for (String file : fileNames) {
File f = new File(file);
if (!f.exists()) {
log.error("File: " + f + " does not exist");
throw new IOException("File: " + f + " does not exist");
}
}
//System.out.println("Time to check file list = "
// + (System.currentTimeMillis() - start2));
}
return fileNames;
} | java | {
"resource": ""
} |
q175224 | GradsDataDescriptorFile.getDDFPath | test | private String getDDFPath() {
if (pathToDDF == null) {
int lastSlash = ddFile.lastIndexOf("/");
if (lastSlash < 0) {
lastSlash = ddFile.lastIndexOf(File.separator);
}
pathToDDF = (lastSlash < 0)
? ""
: ddFile.substring(0, lastSlash + 1);
}
return pathToDDF;
} | java | {
"resource": ""
} |
q175225 | GradsDataDescriptorFile.getFullPath | test | private String getFullPath(String filename) {
String file;
String ddfPath = getDDFPath();
if (filename.startsWith("^")) {
file = filename.replace("^", "");
file = ddfPath + file;
} else {
File f = new File(filename);
if (!f.isAbsolute()) {
file = ddfPath + filename;
} else {
file = filename;
}
}
return file;
} | java | {
"resource": ""
} |
q175226 | GradsDataDescriptorFile.addChsub | test | private void addChsub(Chsub sub) {
if (chsubs == null) {
chsubs = new ArrayList<>();
}
chsubs.add(sub);
} | java | {
"resource": ""
} |
q175227 | TimeCoordIntvDateValue.convertReferenceDate | test | public TimeCoordIntvValue convertReferenceDate(CalendarDate refDate, CalendarPeriod timeUnit) {
if (timeUnit == null) {
throw new IllegalArgumentException("null time unit");
}
int startOffset = timeUnit.getOffset(refDate, start); // LOOK wrong - not dealing with value ??
int endOffset = timeUnit.getOffset(refDate, end);
return new TimeCoordIntvValue(startOffset, endOffset);
} | java | {
"resource": ""
} |
q175228 | Nidsheader.readWMO | test | int readWMO(ucar.unidata.io.RandomAccessFile raf ) throws IOException
{
int pos = 0;
//long actualSize = 0;
raf.seek(pos);
int readLen = 35;
// Read in the contents of the NEXRAD Level III product head
byte[] b = new byte[readLen];
int rc = raf.read(b);
if ( rc != readLen )
{
// out.println(" error reading nids product header");
return 0;
}
// new check
int iarr2_1 = bytesToInt(b[0], b[1], false);
int iarr2_16 = bytesToInt(b[30], b[31], false);
int iarr2_10 = bytesToInt(b[18], b[19], false);
int iarr2_7 = bytesToInt(b[12], b[13], false);
if ( ( iarr2_1 == iarr2_16 ) &&
( ( iarr2_1 >= 16 ) && ( iarr2_1 <= 299) ) &&
( iarr2_10 == -1 ) &&
( iarr2_7 < 10000 ) ) {
noHeader = true;
return 1;
}
//Get product message header into a string for processing
String pib = new String(b, CDM.utf8Charset);
if( pib.indexOf("SDUS")!= -1){
noHeader = false;
return 1;
} else if ( raf.getLocation().indexOf(".nids") != -1) {
noHeader = true;
return 1;
// } else if(checkMsgHeader(raf) == 1) {
// noHeader = true;
// return 1;
} else
return 0;
} | java | {
"resource": ""
} |
q175229 | Nidsheader.getUncompData | test | public byte[] getUncompData(int offset, int len){
if( len == 0 ) len = uncompdata.length - offset;
byte[] data = new byte[len];
System.arraycopy(uncompdata, offset, data, 0, len);
return data;
} | java | {
"resource": ""
} |
q175230 | Nidsheader.pcode_12n13n14 | test | int pcode_12n13n14( int[] pos, int[] dlen, int hoff, int len, boolean isZ, String structName, int code )
{
//int vlen = len;
int vlen = 0;
for(int i=0; i<len; i++ ){
vlen = vlen + dlen[i];
}
ArrayList dims = new ArrayList();
Dimension sDim = new Dimension("graphicSymbolSize", vlen);
ncfile.addDimension( null, sDim);
dims.add( sDim);
Structure dist = new Structure(ncfile, null, null, structName);
dist.setDimensions(dims);
ncfile.addVariable(null, dist);
dist.addAttribute( new Attribute(CDM.LONG_NAME, "special graphic symbol for code "+code));
Variable i0 = new Variable(ncfile, null, dist, "x_start");
i0.setDimensions((String)null);
i0.setDataType(DataType.FLOAT);
i0.addAttribute( new Attribute(CDM.UNITS, "KM"));
dist.addMemberVariable(i0);
Variable j0 = new Variable(ncfile, null, dist, "y_start");
j0.setDimensions((String)null);
j0.setDataType(DataType.FLOAT);
j0.addAttribute( new Attribute(CDM.UNITS, "KM"));
dist.addMemberVariable(j0);
int[] pos1 = new int[len];
int[] dlen1 = new int[len];
System.arraycopy(dlen, 0, dlen1, 0, len);
System.arraycopy(pos, 0, pos1, 0, len);
dist.setSPobject( new Vinfo ( 0, 0, 0, 0, hoff, 0, isR, isZ, pos1, dlen1, code, 0));
return 1;
} | java | {
"resource": ""
} |
q175231 | Nidsheader.pcode_25 | test | int pcode_25( int[] pos, int hoff, int len, boolean isZ )
{
ArrayList dims = new ArrayList();
Dimension sDim = new Dimension("circleSize", len);
ncfile.addDimension( null, sDim);
dims.add( sDim);
Structure dist = new Structure(ncfile, null, null, "circleStruct");
dist.setDimensions(dims);
ncfile.addVariable(null, dist);
dist.addAttribute( new Attribute(CDM.LONG_NAME, "Circle Packet"));
Variable ii0 = new Variable(ncfile, null, dist, "x_center");
ii0.setDimensions((String)null);
ii0.setDataType(DataType.SHORT);
dist.addMemberVariable(ii0);
Variable ii1 = new Variable(ncfile, null, dist, "y_center");
ii1.setDimensions((String)null);
ii1.setDataType(DataType.SHORT);
dist.addMemberVariable(ii1);
Variable jj0 = new Variable(ncfile, null, dist, "radius");
jj0.setDimensions((String)null);
jj0.setDataType(DataType.SHORT);
dist.addMemberVariable(jj0);
int[] pos1 = new int[len];
System.arraycopy(pos, 0, pos1, 0, len);
dist.setSPobject( new Vinfo (0, 0, 0, 0, hoff, 0, isR, isZ, pos1, null, 25, 0));
return 1;
} | java | {
"resource": ""
} |
q175232 | Nidsheader.checkMsgHeader | test | int checkMsgHeader(ucar.unidata.io.RandomAccessFile raf ) throws IOException
{
int rc;
long actualSize ;
int readLen ;
actualSize = raf.length();
int pos = 0;
raf.seek(pos);
// Read in the whole contents of the NEXRAD Level III product since
// some product require to go through the whole file to build the struct of file.
readLen = (int)actualSize;
byte[] b = new byte[readLen];
rc = raf.read(b);
if ( rc != readLen )
{
log.warn(" error reading nids product header "+raf.getLocation());
}
ByteBuffer bos = ByteBuffer.wrap(b);
return read_msghead( bos, 0 );
} | java | {
"resource": ""
} |
q175233 | Nidsheader.pcode_5 | test | int pcode_5( int[] pos, int hoff, int len, boolean isZ )
{
ArrayList dims = new ArrayList();
//int vlen =len;
Dimension sDim = new Dimension("windBarbSize", len);
ncfile.addDimension( null, sDim);
dims.add( sDim);
Structure dist = new Structure(ncfile, null, null, "vectorArrow");
dist.setDimensions(dims);
ncfile.addVariable(null, dist);
dist.addAttribute( new Attribute(CDM.LONG_NAME, "Vector Arrow Data"));
Variable i0 = new Variable(ncfile, null, dist, "x_start");
i0.setDimensions((String)null);
i0.setDataType(DataType.SHORT);
i0.addAttribute( new Attribute(CDM.UNITS, "KM"));
dist.addMemberVariable(i0);
Variable j0 = new Variable(ncfile, null, dist, "y_start");
j0.setDimensions((String)null);
j0.setDataType(DataType.SHORT);
j0.addAttribute( new Attribute(CDM.UNITS, "KM"));
dist.addMemberVariable(j0);
Variable direct = new Variable(ncfile, null, dist, "direction");
direct.setDimensions((String)null);
direct.setDataType(DataType.SHORT);
direct.addAttribute( new Attribute(CDM.UNITS, "degree"));
dist.addMemberVariable(direct);
Variable speed = new Variable(ncfile, null, dist, "arrowLength");
speed.setDimensions((String)null);
speed.setDataType(DataType.SHORT);
speed.addAttribute( new Attribute(CDM.UNITS, "pixels"));
dist.addMemberVariable(speed);
Variable speed1 = new Variable(ncfile, null, dist, "arrowHeadLength");
speed1.setDimensions((String)null);
speed1.setDataType(DataType.SHORT);
speed1.addAttribute( new Attribute(CDM.UNITS, "pixels"));
dist.addMemberVariable(speed1);
int[] pos1 = new int[len];
System.arraycopy(pos, 0, pos1, 0, len);
dist.setSPobject( new Vinfo (0, 0, 0, 0, hoff, 0, isR, isZ, pos1, null, 4, 0));
return 1;
} | java | {
"resource": ""
} |
q175234 | Nidsheader.pcode_128 | test | int pcode_128( int[] pos, int[] size, int code, int hoff, int len, String structName, String abbre, boolean isZ )
{
//int vlen = len;
ArrayList dims = new ArrayList();
Dimension sDim = new Dimension("textStringSize"+ abbre + code, len);
ncfile.addDimension( null, sDim);
dims.add( sDim);
Structure dist = new Structure(ncfile, null, null, structName + abbre);
dist.setDimensions(dims);
ncfile.addVariable(null, dist);
dist.addAttribute( new Attribute(CDM.LONG_NAME, "text and special symbol for code "+code));
if(code == 8){
Variable strVal = new Variable(ncfile, null, dist, "strValue");
strVal.setDimensions((String)null);
strVal.setDataType(DataType.SHORT);
strVal.addAttribute( new Attribute(CDM.UNITS, ""));
dist.addMemberVariable(strVal);
}
Variable i0 = new Variable(ncfile, null, dist, "x_start");
i0.setDimensions((String)null);
i0.setDataType(DataType.SHORT);
i0.addAttribute( new Attribute(CDM.UNITS, "KM"));
dist.addMemberVariable(i0);
Variable j0 = new Variable(ncfile, null, dist, "y_start");
j0.setDimensions((String)null);
j0.setDataType(DataType.SHORT);
j0.addAttribute( new Attribute(CDM.UNITS, "KM"));
dist.addMemberVariable(j0);
Variable tstr = new Variable(ncfile, null, dist, "textString" );
tstr.setDimensions((String)null);
tstr.setDataType(DataType.STRING);
tstr.addAttribute( new Attribute(CDM.UNITS, ""));
dist.addMemberVariable(tstr);
int[] pos1 = new int[len];
System.arraycopy(pos, 0, pos1, 0, len);
dist.setSPobject( new Vinfo ( 0, 0, 0, 0, hoff, 0, isR, isZ, pos1, size, code, 0));
return 1;
} | java | {
"resource": ""
} |
q175235 | Nidsheader.pcode_10n9 | test | int pcode_10n9( int[] pos, int[] dlen, int hoff, int len, boolean isZ )
{
ArrayList dims = new ArrayList();
Variable v ;
int vlen = 0;
for(int i=0; i<len; i++ ){
vlen = vlen + dlen[i];
}
Dimension sDim = new Dimension("unlinkedVectorSize", vlen);
ncfile.addDimension( null, sDim);
dims.add( sDim);
Structure dist = new Structure(ncfile, null, null, "unlinkedVectorStruct");
dist.setDimensions(dims);
ncfile.addVariable(null, dist);
dist.addAttribute( new Attribute(CDM.LONG_NAME, "Unlinked Vector Packet"));
v = new Variable(ncfile, null, null, "iValue");
v.setDataType(DataType.SHORT);
v.setDimensions((String)null);
dist.addMemberVariable(v);
Variable ii0 = new Variable(ncfile, null, dist, "x_start");
ii0.setDimensions((String)null);
ii0.setDataType(DataType.SHORT);
dist.addMemberVariable(ii0);
Variable ii1 = new Variable(ncfile, null, dist, "y_start");
ii1.setDimensions((String)null);
ii1.setDataType(DataType.SHORT);
dist.addMemberVariable(ii1);
Variable jj0 = new Variable(ncfile, null, dist, "x_end");
jj0.setDimensions((String)null);
jj0.setDataType(DataType.SHORT);
dist.addMemberVariable(jj0);
Variable jj1 = new Variable(ncfile, null, dist, "y_end");
jj1.setDimensions((String)null);
jj1.setDataType(DataType.SHORT);
dist.addMemberVariable(jj1);
int[] pos1 = new int[len];
int[] dlen1 = new int[len];
System.arraycopy(pos, 0, pos1, 0, len);
System.arraycopy(dlen, 0, dlen1, 0, len);
dist.setSPobject( new Vinfo ( 0, 0, 0, 0, hoff, 0, isR, isZ, pos1, dlen1, 10, 0));
return 1;
} | java | {
"resource": ""
} |
q175236 | Nidsheader.getLevels | test | public int[] getLevels(int nlevel, short[] th) {
int [] levels = new int[nlevel];
int ival;
int isign;
for ( int i = 0; i < nlevel; i++ ) { /* calibrated data values */
ival = convertShort2unsignedInt(th[i]);
if ( (ival & 0x00008000) == 0 ) {
isign = -1;
if ( (ival & 0x00000100) == 0 ) isign = 1;
levels[i] = isign * ( ival & 0x000000FF );
} else {
levels[i] = -9999 + ( ival & 0x000000FF);
}
}
return levels;
} | java | {
"resource": ""
} |
q175237 | Nidsheader.getDualpolLevels | test | public int[] getDualpolLevels( short[] th) {
int inc = th.length;
int [] levels = new int[ inc]; //th[2] ];
for ( int i = 0; i < inc; i++ ) { /* calibrated data values */
levels[i] = th[i];
}
return levels;
} | java | {
"resource": ""
} |
q175238 | Nidsheader.addVariable | test | void addVariable(String pName, String longName, NetcdfFile nc, ArrayList dims, String coordinates,
DataType dtype, String ut, long hoff, long hedsiz, boolean isZ, int nlevel, int[] levels, int iscale)
{
Variable v = new Variable(nc, null, null, pName);
v.setDataType(dtype);
v.setDimensions(dims);
ncfile.addVariable(null, v);
v.addAttribute( new Attribute(CDM.LONG_NAME, longName));
v.addAttribute( new Attribute(CDM.UNITS, ut));
v.addAttribute( new Attribute(_Coordinate.Axes, coordinates));
v.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, levels, iscale, nlevel));
} | java | {
"resource": ""
} |
q175239 | Nidsheader.addParameter | test | void addParameter(String pName, String longName, NetcdfFile nc, ArrayList dims, Attribute att,
DataType dtype, String ut, long hoff, long doff, boolean isZ, int y0)
{
String vName = pName;
Variable vVar = new Variable(nc, null, null, vName);
vVar.setDataType(dtype);
if( dims != null ) vVar.setDimensions(dims);
else vVar.setDimensions("");
if(att != null ) vVar.addAttribute(att);
vVar.addAttribute( new Attribute(CDM.UNITS, ut));
vVar.addAttribute( new Attribute(CDM.LONG_NAME, longName));
nc.addVariable(null, vVar);
vVar.setSPobject( new Vinfo (numX, numX0, numY, y0, hoff, doff, isR, isZ, null, null, 0, 0));
} | java | {
"resource": ""
} |
q175240 | Nidsheader.uncompressed | test | byte[] uncompressed( ByteBuffer buf, int offset, int uncomplen ) throws IOException
{
byte[] header = new byte[offset];
buf.position(0);
buf.get(header);
byte[] out = new byte[offset+uncomplen];
System.arraycopy(header, 0, out, 0, offset);
CBZip2InputStream cbzip2 = new CBZip2InputStream();
int numCompBytes = buf.remaining();
byte[] bufc = new byte[numCompBytes];
buf.get(bufc, 0, numCompBytes);
ByteArrayInputStream bis = new ByteArrayInputStream(bufc, 2, numCompBytes - 2);
//CBZip2InputStream cbzip2 = new CBZip2InputStream(bis);
cbzip2.setStream(bis);
int total = 0;
int nread;
byte[] ubuff = new byte[40000];
byte[] obuff = new byte[40000];
try {
while ((nread = cbzip2.read(ubuff)) != -1) {
if (total + nread > obuff.length) {
byte[] temp = obuff;
obuff = new byte[temp.length * 2];
System.arraycopy(temp, 0, obuff, 0, temp.length);
}
System.arraycopy(ubuff, 0, obuff, total, nread);
total += nread;
}
if (obuff.length >= 0)
System.arraycopy(obuff, 0, out, offset, total);
} catch (BZip2ReadException ioe) {
log.warn("Nexrad2IOSP.uncompress "+raf.getLocation(), ioe);
}
return out;
} | java | {
"resource": ""
} |
q175241 | Nidsheader.getUInt | test | int getUInt( byte[] b, int num )
{
int base=1;
int i;
int word=0;
int bv[] = new int[num];
for (i = 0; i<num; i++ )
{
bv[i] = convertunsignedByte2Short(b[i]);
}
/*
** Calculate the integer value of the byte sequence
*/
for ( i = num-1; i >= 0; i-- ) {
word += base * bv[i];
base *= 256;
}
return word;
} | java | {
"resource": ""
} |
q175242 | Nidsheader.getInt | test | int getInt( byte[] b, int num )
{
int base=1;
int i;
int word=0;
int bv[] = new int[num];
for (i = 0; i<num; i++ )
{
bv[i] = convertunsignedByte2Short(b[i]);
}
if( bv[0] > 127 )
{
bv[0] -= 128;
base = -1;
}
/*
** Calculate the integer value of the byte sequence
*/
for ( i = num-1; i >= 0; i-- ) {
word += base * bv[i];
base *= 256;
}
return word;
} | java | {
"resource": ""
} |
q175243 | Nidsheader.convert | test | protected Object convert( byte[] barray, DataType dataType, int nelems, int byteOrder) {
if (dataType == DataType.BYTE) {
return barray;
}
if (dataType == DataType.CHAR) {
return IospHelper.convertByteToChar( barray);
}
ByteBuffer bbuff = ByteBuffer.wrap( barray);
if (byteOrder >= 0)
bbuff.order( byteOrder == ucar.unidata.io.RandomAccessFile.LITTLE_ENDIAN? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
if (dataType == DataType.SHORT) {
ShortBuffer tbuff = bbuff.asShortBuffer();
short[] pa = new short[nelems];
tbuff.get( pa);
return pa;
} else if (dataType == DataType.INT) {
IntBuffer tbuff = bbuff.asIntBuffer();
int[] pa = new int[nelems];
tbuff.get( pa);
return pa;
} else if (dataType == DataType.FLOAT) {
FloatBuffer tbuff = bbuff.asFloatBuffer();
float[] pa = new float[nelems];
tbuff.get( pa);
return pa;
} else if (dataType == DataType.DOUBLE) {
DoubleBuffer tbuff = bbuff.asDoubleBuffer();
double[] pa = new double[nelems];
tbuff.get( pa);
return pa;
}
throw new IllegalStateException();
} | java | {
"resource": ""
} |
q175244 | DapController.doDMR | test | protected void
doDMR(DapRequest drq, DapContext cxt)
throws IOException
{
// Convert the url to an absolute path
String realpath = getResourcePath(drq, drq.getDatasetPath());
DSP dsp = DapCache.open(realpath, cxt);
DapDataset dmr = dsp.getDMR();
/* Annotate with our endianness */
ByteOrder order = (ByteOrder) cxt.get(Dap4Util.DAP4ENDIANTAG);
setEndianness(dmr, order);
// Process any constraint view
CEConstraint ce = null;
String sce = drq.queryLookup(DapProtocol.CONSTRAINTTAG);
ce = CEConstraint.compile(sce, dmr);
setConstraint(dmr, ce);
// Provide a PrintWriter for capturing the DMR.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
// Get the DMR as a string
DMRPrinter dapprinter = new DMRPrinter(dmr, ce, pw, drq.getFormat());
if(cxt.get(Dap4Util.DAP4TESTTAG) != null)
dapprinter.testprint();
else
dapprinter.print();
pw.close();
sw.close();
String sdmr = sw.toString();
if(DEBUG)
System.err.println("Sending: DMR:\n" + sdmr);
addCommonHeaders(drq);// Add relevant headers
// Wrap the outputstream with a Chunk writer
OutputStream out = drq.getOutputStream();
ChunkWriter cw = new ChunkWriter(out, RequestMode.DMR, order);
cw.cacheDMR(sdmr);
cw.close();
} | java | {
"resource": ""
} |
q175245 | DapController.getRequestState | test | protected DapRequest
getRequestState(HttpServletRequest rq, HttpServletResponse rsp)
throws IOException
{
return new DapRequest(this, rq, rsp);
} | java | {
"resource": ""
} |
q175246 | DapController.senderror | test | protected void
senderror(DapRequest drq, int httpcode, Throwable t)
throws IOException
{
if(httpcode == 0) httpcode = HttpServletResponse.SC_BAD_REQUEST;
ErrorResponse err = new ErrorResponse();
err.setCode(httpcode);
if(t == null) {
err.setMessage("Servlet error: " + drq.getURL());
} else {
StringWriter sw = new StringWriter();
PrintWriter p = new PrintWriter(sw);
t.printStackTrace(p);
p.close();
sw.close();
err.setMessage(sw.toString());
}
err.setContext(drq.getURL());
String errormsg = err.buildXML();
drq.getResponse().sendError(httpcode, errormsg);
} | java | {
"resource": ""
} |
q175247 | Rubberband.anchor | test | public boolean anchor(Point p) {
firstStretch = true;
anchorPt.x = p.x;
anchorPt.y = p.y;
stretchedPt.x = lastPt.x = anchorPt.x;
stretchedPt.y = lastPt.y = anchorPt.y;
return true;
} | java | {
"resource": ""
} |
q175248 | Rubberband.stretch | test | public void stretch(Point p) {
lastPt.x = stretchedPt.x;
lastPt.y = stretchedPt.y;
stretchedPt.x = p.x;
stretchedPt.y = p.y;
Graphics2D g = (Graphics2D) component.getGraphics();
if(g != null) {
try {
g.setXORMode(component.getBackground());
if(firstStretch == true)
firstStretch = false;
else
drawLast(g);
drawNext(g);
}
finally {
g.dispose();
} // try
} // if
} | java | {
"resource": ""
} |
q175249 | Rubberband.getBounds | test | public Rectangle getBounds() {
return new Rectangle(stretchedPt.x < anchorPt.x ?
stretchedPt.x : anchorPt.x,
stretchedPt.y < anchorPt.y ?
stretchedPt.y : anchorPt.y,
Math.abs(stretchedPt.x - anchorPt.x),
Math.abs(stretchedPt.y - anchorPt.y));
} | java | {
"resource": ""
} |
q175250 | Rubberband.lastBounds | test | public Rectangle lastBounds() {
return new Rectangle(
lastPt.x < anchorPt.x ? lastPt.x : anchorPt.x,
lastPt.y < anchorPt.y ? lastPt.y : anchorPt.y,
Math.abs(lastPt.x - anchorPt.x),
Math.abs(lastPt.y - anchorPt.y));
} | java | {
"resource": ""
} |
q175251 | DateFormatter.dateOnlyFormat | test | private Date dateOnlyFormat(String text) throws java.text.ParseException {
text = (text == null) ? "" : text.trim();
dateOnlyFormat();
return dateOnlyFormat.parse(text);
} | java | {
"resource": ""
} |
q175252 | Table.replaceDataVars | test | protected void replaceDataVars(StructureMembers sm) {
for (StructureMembers.Member m : sm.getMembers()) {
VariableSimpleIF org = this.cols.get(m.getName());
int rank = org.getRank();
List<Dimension> orgDims = org.getDimensions();
// only keep the last n
int n = m.getShape().length;
List<Dimension> dims = orgDims.subList(rank-n, rank);
VariableSimpleImpl result = new VariableSimpleImpl(org.getShortName(), org.getDescription(), org.getUnitsString(), org.getDataType(), dims);
for (Attribute att : org.getAttributes()) result.add(att);
this.cols.put(m.getName(), result);
}
} | java | {
"resource": ""
} |
q175253 | ErddapMath2.ensureArraySizeOkay | test | public static void ensureArraySizeOkay(long tSize, String attributeTo) {
if (tSize >= Integer.MAX_VALUE)
throw new RuntimeException(memoryTooMuchData + " " +
MessageFormat.format(memoryArraySize, "" + tSize, "" + Integer.MAX_VALUE) +
(attributeTo == null || attributeTo.length() == 0? "" : " (" + attributeTo + ")"));
} | java | {
"resource": ""
} |
q175254 | GribNumbers.int2 | test | public static int int2(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
return int2(a, b);
} | java | {
"resource": ""
} |
q175255 | GribNumbers.uint | test | public static int uint(RandomAccessFile raf) throws IOException {
int a = raf.read();
return (int) DataType.unsignedByteToShort((byte) a);
} | java | {
"resource": ""
} |
q175256 | GribNumbers.int3 | test | public static int int3(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
int c = raf.read();
return int3(a, b, c);
} | java | {
"resource": ""
} |
q175257 | GribNumbers.uint2 | test | public static int uint2(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
return uint2(a, b);
} | java | {
"resource": ""
} |
q175258 | GribNumbers.uint3 | test | public static int uint3(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
int c = raf.read();
return uint3(a, b, c);
} | java | {
"resource": ""
} |
q175259 | GribNumbers.float4 | test | public static float float4(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
int c = raf.read();
int d = raf.read();
return float4(a, b, c, d);
} | java | {
"resource": ""
} |
q175260 | GribNumbers.float4 | test | public static float float4(int a, int b, int c, int d) {
int sgn, mant, exp;
mant = b << 16 | c << 8 | d;
if (mant == 0) {
return 0.0f;
}
sgn = -(((a & 128) >> 6) - 1);
exp = (a & 127) - 64;
return (float) (sgn * Math.pow(16.0, exp - 6) * mant);
} | java | {
"resource": ""
} |
q175261 | GribNumbers.int8 | test | public static long int8(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
int c = raf.read();
int d = raf.read();
int e = raf.read();
int f = raf.read();
int g = raf.read();
int h = raf.read();
return (1 - ((a & 128) >> 6))
* ((long)(a & 127) << 56 | (long) b << 48 | (long) c << 40 | (long) d << 32 | e << 24
| f << 16 | g << 8 | h);
} | java | {
"resource": ""
} |
q175262 | GribNumbers.countBits | test | public static int countBits(byte[] bitmap) {
int bits = 0;
for (byte b : bitmap) {
short s = DataType.unsignedByteToShort(b);
bits += Long.bitCount(s);
}
return bits;
} | java | {
"resource": ""
} |
q175263 | LambertConformal.constructCopy | test | @Override
public ProjectionImpl constructCopy() {
ProjectionImpl result = new LambertConformal(getOriginLat(), getOriginLon(), getParallelOne(), getParallelTwo(),
getFalseEasting(), getFalseNorthing(), earth_radius);
result.setDefaultMapArea(defaultMapArea);
result.setName(name);
return result;
} | java | {
"resource": ""
} |
q175264 | LambertConformal.toWKS | test | public String toWKS() {
StringBuilder sbuff = new StringBuilder();
sbuff.append("PROJCS[\"").append(getName()).append("\",");
if (true) {
sbuff.append("GEOGCS[\"Normal Sphere (r=6371007)\",");
sbuff.append("DATUM[\"unknown\",");
sbuff.append("SPHEROID[\"sphere\",6371007,0]],");
} else {
sbuff.append("GEOGCS[\"WGS 84\",");
sbuff.append("DATUM[\"WGS_1984\",");
sbuff.append("SPHEROID[\"WGS 84\",6378137,298.257223563],");
sbuff.append("TOWGS84[0,0,0,0,0,0,0]],");
}
sbuff.append("PRIMEM[\"Greenwich\",0],");
sbuff.append("UNIT[\"degree\",0.0174532925199433]],");
sbuff.append("PROJECTION[\"Lambert_Conformal_Conic_1SP\"],");
sbuff.append("PARAMETER[\"latitude_of_origin\",").append(getOriginLat()).append("],"); // LOOK assumes getOriginLat = getParellel
sbuff.append("PARAMETER[\"central_meridian\",").append(getOriginLon()).append("],");
sbuff.append("PARAMETER[\"scale_factor\",1],");
sbuff.append("PARAMETER[\"false_easting\",").append(falseEasting).append("],");
sbuff.append("PARAMETER[\"false_northing\",").append(falseNorthing).append("],");
return sbuff.toString();
} | java | {
"resource": ""
} |
q175265 | Escape.entityEscape | test | static public String
entityEscape(String s, String wrt)
{
if(wrt == null)
wrt = ENTITYESCAPES;
StringBuilder escaped = new StringBuilder();
for(int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
int index = wrt.indexOf(c);
if(index < 0)
escaped.append(c);
else switch (c) {
case '&':
escaped.append('&' + ENTITY_AMP + ';');
break;
case '<':
escaped.append('&' + ENTITY_LT + ';');
break;
case '>':
escaped.append('&' + ENTITY_GT + ';');
break;
case '"':
escaped.append('&' + ENTITY_QUOT + ';');
break;
case '\'':
escaped.append('&' + ENTITY_APOS + ';');
break;
case '\r':
case '\t':
case '\n':
escaped.append(c); // These are the only legal control chars
break;
case '\0':
// What to do about nul? currrently we suppress it
break;
default:
if(c >= ' ')
escaped.append(c);
break;
}
}
return escaped.toString();
} | java | {
"resource": ""
} |
q175266 | Escape.backslashUnescape | test | static public String
backslashUnescape(String s)
{
StringBuilder clear = new StringBuilder();
for(int i = 0; i < s.length(); ) {
char c = s.charAt(i++);
if(c == '\\') {
c = s.charAt(i++);
switch (c) {
case 'r':
c = '\r';
break;
case 'n':
c = '\n';
break;
case 't':
c = '\t';
break;
case 'f':
c = '\f';
break;
default:
break;
}
clear.append(c);
} else
clear.append(c);
}
return clear.toString();
} | java | {
"resource": ""
} |
q175267 | Escape.backslashsplit | test | static public List<String>
backslashsplit(String s, char sep)
{
List<String> path = new ArrayList<String>();
int len = s.length();
StringBuilder piece = new StringBuilder();
int i = 0;
for(; i <= len - 1; i++) {
char c = s.charAt(i);
if(c == '\\' && i < (len - 1)) {
piece.append(c); // keep escapes in place
piece.append(s.charAt(++i));
} else if(c == sep) {
path.add(piece.toString());
piece.setLength(0);
} else
piece.append(c);
}
path.add(piece.toString());
return path;
} | java | {
"resource": ""
} |
q175268 | Fmrc.makeFmrcInv | test | private FmrcInv makeFmrcInv(Formatter debug) throws IOException {
try {
Map<CalendarDate, FmrInv> fmrMap = new HashMap<>(); // all files are grouped by run date in an FmrInv
List<FmrInv> fmrList = new ArrayList<>(); // an fmrc is a collection of fmr
// get the inventory, sorted by path
for (MFile f : manager.getFilesSorted()) {
Map<String, String> filesRunDateMap = ((MFileCollectionManager) manager).getFilesRunDateMap();
CalendarDate runDate;
if (!filesRunDateMap.isEmpty()) {
// run time has been defined in NcML FMRC agg by the coord attribute,
// so explicitly set it in the dataset using the _Coordinate.ModelBaseDate
// global attribute, otherwise the run time offsets might be incorrectly
// computed if the incorrect run date is found in GridDatasetInv.java (line
// 177 with comment // Look: not really right )
runDate = CalendarDate.parseISOformat(null, filesRunDateMap.get(f.getPath()));
Element element = new Element("netcdf", ncNSHttps);
Element runDateAttr = ncmlWriter.makeAttributeElement(new Attribute(_Coordinate.ModelRunDate, runDate.toString()));
config.innerNcml = element.addContent(runDateAttr);
}
GridDatasetInv inv;
try {
inv = GridDatasetInv.open(manager, f, config.innerNcml); // inventory is discovered for each GDS
} catch (IOException ioe) {
logger.warn("Error opening " + f.getPath() + "(skipped)", ioe);
continue; // skip
}
runDate = inv.getRunDate();
if (debug != null) debug.format(" opened %s rundate = %s%n", f.getPath(), inv.getRunDateString());
// add to fmr for that rundate
FmrInv fmr = fmrMap.get(runDate);
if (fmr == null) {
fmr = new FmrInv(runDate);
fmrMap.put(runDate, fmr);
fmrList.add(fmr);
}
fmr.addDataset(inv, debug);
}
if (debug != null) debug.format("%n");
// finish the FmrInv
Collections.sort(fmrList);
for (FmrInv fmr : fmrList) {
fmr.finish();
if (logger.isDebugEnabled())
logger.debug("Fmrc:"+config.name+": made fmr with rundate="+fmr.getRunDate()+" nfiles= "+fmr.getFiles().size());
}
return new FmrcInv("fmrc:"+manager.getCollectionName(), fmrList, config.fmrcConfig.regularize);
} catch (Throwable t) {
logger.error("makeFmrcInv", t);
throw new RuntimeException(t);
}
} | java | {
"resource": ""
} |
q175269 | LogCategorizer.getServiceSpecial | test | static public String getServiceSpecial(String path) {
String ss = null;
if (path.startsWith("/dqcServlet"))
ss = "dqcServlet";
else if (path.startsWith("/cdmvalidator"))
ss = "cdmvalidator";
return ss;
} | java | {
"resource": ""
} |
q175270 | DGrid.projectedComponents | test | public int projectedComponents(boolean constrained) {
int comp;
if (constrained) {
comp = ((DArray)arrayVar).isProject() ? 1 : 0;
Enumeration e = mapVars.elements();
while (e.hasMoreElements()) {
if (((DArray) e.nextElement()).isProject())
comp++;
}
} else {
comp = 1 + mapVars.size();
}
return comp;
} | java | {
"resource": ""
} |
q175271 | BufrIdentificationSection.getReferenceTime | test | public final CalendarDate getReferenceTime() {
int sec = (second < 0 || second > 59) ? 0 : second;
return CalendarDate.of(null, year, month, day, hour, minute, sec);
} | java | {
"resource": ""
} |
q175272 | ArrayStructureBBsection.factory | test | static public ArrayStructureBB factory(ArrayStructureBB org, Section section) {
if (section == null || section.computeSize() == org.getSize())
return org;
return new ArrayStructureBBsection(org.getStructureMembers(), org.getShape(), org.getByteBuffer(), section);
} | java | {
"resource": ""
} |
q175273 | LuceneIndexer.main1 | test | public static void main1(String[] args) {
if (INDEX_DIR.exists()) {
System.out.println("Cannot save index to '" + INDEX_DIR + "' directory, please delete it first");
System.exit(1);
}
LuceneIndexer indexer = new LuceneIndexer();
Date start = new Date();
try {
IndexWriter writer = new IndexWriter(INDEX_DIR, new StandardAnalyzer(), true);
System.out.println("Indexing to directory '" + INDEX_DIR + "'...");
indexer.indexDocs(writer, DOC_DIR);
System.out.println("Optimizing...");
writer.optimize();
writer.close();
Date end = new Date();
System.out.println(end.getTime() - start.getTime() + " total milliseconds");
} catch (IOException e) {
System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage());
}
} | java | {
"resource": ""
} |
q175274 | Grib1Index.readRecord | test | private Grib1Record readRecord(Grib1IndexProto.Grib1Record p) {
Grib1SectionIndicator is = new Grib1SectionIndicator(p.getGribMessageStart(), p.getGribMessageLength());
Grib1SectionProductDefinition pds = new Grib1SectionProductDefinition(p.getPds().toByteArray());
Grib1SectionGridDefinition gds = pds.gdsExists() ? gdsList.get(p.getGdsIdx()) : new Grib1SectionGridDefinition(pds);
Grib1SectionBitMap bms = pds.bmsExists() ? new Grib1SectionBitMap(p.getBmsPos()) : null;
Grib1SectionBinaryData dataSection = new Grib1SectionBinaryData(p.getDataPos(), p.getDataLen());
return new Grib1Record(p.getHeader().toByteArray(), is, gds, pds, bms, dataSection);
} | java | {
"resource": ""
} |
q175275 | M3IOConvention.isMine | test | public static boolean isMine(NetcdfFile ncfile) {
return (null != ncfile.findGlobalAttribute("XORIG"))
&& (null != ncfile.findGlobalAttribute("YORIG"))
&& (null != ncfile.findGlobalAttribute("XCELL"))
&& (null != ncfile.findGlobalAttribute("YCELL"))
&& (null != ncfile.findGlobalAttribute("NCOLS"))
&& (null != ncfile.findGlobalAttribute("NROWS"));
// M3IOVGGridConvention - is this true for this class ??
// return ncFile.findGlobalAttribute( "VGLVLS" ) != null && isValidM3IOFile_( ncFile );
} | java | {
"resource": ""
} |
q175276 | M3IOConvention.makeUTMProjection | test | private CoordinateTransform makeUTMProjection(NetcdfDataset ds) {
int zone = (int) findAttributeDouble(ds, "P_ALP");
double ycent = findAttributeDouble(ds, "YCENT");
//double lon0 = findAttributeDouble( "X_CENT");
//double lat0 = findAttributeDouble( "Y_CENT");
/**
* Construct a UTM Projection.
* @param zone - UTM zone
* @param if ycent < 0, then isNorth = False
*/
boolean isNorth = true;
if (ycent < 0)
isNorth = false;
UtmProjection utm = new UtmProjection(zone, isNorth);
return new ProjectionCT("UTM", "EPSG", utm);
} | java | {
"resource": ""
} |
q175277 | AreaServiceProvider.reacquire | test | public void reacquire() throws IOException {
try {
areaReader.af = new AreaFile(location);
} catch (Throwable e) {
throw new IOException(e);
}
} | java | {
"resource": ""
} |
q175278 | DateType.before | test | public boolean before(Date d) {
if (isPresent()) return false;
return date.isBefore(CalendarDate.of(d));
} | java | {
"resource": ""
} |
q175279 | DateType.before | test | public boolean before(DateType d) {
if (d.isPresent()) return true;
if (isPresent()) return false;
return date.isBefore(d.getCalendarDate());
} | java | {
"resource": ""
} |
q175280 | DateType.after | test | public boolean after(Date d) {
if (isPresent()) return true;
return date.isAfter(CalendarDate.of(d));
} | java | {
"resource": ""
} |
q175281 | BaseTypePrimitiveVector.setValue | test | public final void setValue(int i, BaseType newVal) {
vals[i] = newVal;
BaseType parent = (BaseType)getTemplate().getParent();
vals[i].setParent(parent);
} | java | {
"resource": ""
} |
q175282 | EnhancementsImpl.addCoordinateSystem | test | public void addCoordinateSystem( CoordinateSystem cs){
if (cs == null)
throw new RuntimeException("Attempted to add null CoordinateSystem to var " + forVar.getFullName());
if (coordSys == null) coordSys = new ArrayList<>(5);
coordSys.add(cs);
} | java | {
"resource": ""
} |
q175283 | EnhancementsImpl.setUnitsString | test | public void setUnitsString( String units) {
this.units = units;
forVar.addAttribute( new Attribute(CDM.UNITS, units));
} | java | {
"resource": ""
} |
q175284 | EnhancementsImpl.getUnitsString | test | public String getUnitsString() {
String result = units;
if ((result == null) && (forVar != null)) {
Attribute att = forVar.findAttribute( CDM.UNITS);
if (att == null) att = forVar.findAttributeIgnoreCase( CDM.UNITS);
if ((att != null) && att.isString())
result = att.getStringValue();
}
return (result == null) ? null : result.trim();
} | java | {
"resource": ""
} |
q175285 | ConfigCatalogInitialization.init | test | public synchronized void init(ReadMode readMode, PreferencesExt prefs) {
if (readMode == null)
readMode = defaultReadMode;
this.prefs = prefs;
trackerNumber = prefs.getLong("trackerNumber", 1);
numberCatalogs = prefs.getInt("numberCatalogs", 10);
nextCatId = prefs.getLong("nextCatId", 1);
makeDebugActions();
this.contentRootPath = this.tdsContext.getThreddsDirectory();
this.contextPath = tdsContext.getContextPath();
reread(readMode, true);
} | java | {
"resource": ""
} |
q175286 | ConfigCatalogInitialization.readCatalog | test | private ConfigCatalog readCatalog(String catalogRelPath, String catalogFullPath) {
URI uri;
try {
// uri = new URI("file:" + StringUtil2.escape(catalogFullPath, "/:-_.")); // needed ?
uri = new URI(this.contextPath + "/catalog/" + catalogRelPath);
} catch (URISyntaxException e) {
logCatalogInit.error(ERROR + "readCatalog(): URISyntaxException=" + e.getMessage());
return null;
}
ConfigCatalogBuilder builder = new ConfigCatalogBuilder();
try {
// read the catalog
logCatalogInit.info("-------readCatalog(): path=" + catalogRelPath);
ConfigCatalog cat = (ConfigCatalog) builder.buildFromLocation(catalogFullPath, uri);
if (builder.hasFatalError()) {
logCatalogInit.error(ERROR + " invalid catalog -- " + builder.getErrorMessage());
return null;
}
if (builder.getErrorMessage().length() > 0)
logCatalogInit.debug(builder.getErrorMessage());
return cat;
} catch (Throwable t) {
logCatalogInit.error(ERROR + " Exception on catalog=" + catalogFullPath + " " + t.getMessage() + "\n log=" + builder.getErrorMessage(), t);
return null;
}
} | java | {
"resource": ""
} |
q175287 | ConfigCatalogInitialization.processDatasets | test | private void processDatasets(long catId, ReadMode readMode, String dirPath, List<Dataset> datasets, Set<String> idMap) throws IOException {
if (exceedLimit) return;
for (Dataset ds : datasets) {
if (datasetTracker.trackDataset(catId, ds, callback)) countDatasets++;
if (maxDatasetsProcess > 0 && countDatasets > maxDatasetsProcess) exceedLimit = true;
// look for duplicate ids
String id = ds.getID();
if (id != null) {
if (idMap.contains(id)) {
logCatalogInit.error(ERROR + "Duplicate id on '" + ds.getName() + "' id= '" + id + "'");
} else {
idMap.add(id);
}
}
if ((ds instanceof DatasetScan) || (ds instanceof FeatureCollectionRef)) continue;
if (ds instanceof CatalogScan) continue;
if (ds instanceof CatalogRef) { // follow catalog refs
CatalogRef catref = (CatalogRef) ds;
String href = catref.getXlinkHref();
// if (logCatalogInit.isDebugEnabled()) logCatalogInit.debug(" catref.getXlinkHref=" + href);
// Check that catRef is relative
if (!href.startsWith("http:")) {
// Clean up relative URLs that start with "./"
if (href.startsWith("./")) {
href = href.substring(2);
}
String path;
String contextPathPlus = this.contextPath + "/";
if (href.startsWith(contextPathPlus)) {
path = href.substring(contextPathPlus.length()); // absolute starting from content root
} else if (href.startsWith("/")) {
// Drop the catRef because it points to a non-TDS served catalog.
logCatalogInit.error(ERROR + "Skipping catalogRef <xlink:href=" + href + ">. Reference is relative to the server outside the context path [" + contextPathPlus + "]. " +
"Parent catalog info: Name=\"" + catref.getParentCatalog().getName() + "\"; Base URI=\"" + catref.getParentCatalog().getUriString() + "\"; dirPath=\"" + dirPath + "\".");
continue;
} else {
path = dirPath + href; // reletive starting from current directory
}
CatalogExt ext = catalogTracker.get(path);
long lastRead = (ext == null) ? 0 : ext.getLastRead();
checkCatalogToRead(readMode, path, false, lastRead);
}
} else {
// recurse through nested datasets
processDatasets(catId, readMode, dirPath, ds.getDatasetsLocal(), idMap);
}
}
} | java | {
"resource": ""
} |
q175288 | ConfigCatalogInitialization.readCatsInDirectory | test | private void readCatsInDirectory(ReadMode readMode, String dirPath, Path directory) throws IOException {
if (exceedLimit) return;
// do any catalogs first
try (DirectoryStream<Path> ds = Files.newDirectoryStream(directory, "*.xml")) {
for (Path p : ds) {
if (!Files.isDirectory(p)) {
// path must be relative to rootDir
String filename = p.getFileName().toString();
String path = dirPath.length() == 0 ? filename : dirPath + "/" + filename; // reletive starting from current directory
CatalogExt ext = catalogTracker.get(path);
long lastRead = (ext == null) ? 0 : ext.getLastRead();
checkCatalogToRead(readMode, path, false, lastRead);
}
}
}
// now recurse into the directory
try (DirectoryStream<Path> ds = Files.newDirectoryStream(directory)) {
for (Path dir : ds) {
if (Files.isDirectory(dir)) {
String dirPathChild = dirPath + "/" + dir.getFileName().toString(); // reletive starting from current directory
readCatsInDirectory(readMode, dirPathChild, dir);
}
}
}
} | java | {
"resource": ""
} |
q175289 | LatLonPointImpl.betweenLon | test | static public boolean betweenLon(double lon, double lonBeg, double lonEnd) {
lonBeg = lonNormal(lonBeg, lon);
lonEnd = lonNormal(lonEnd, lon);
return (lon >= lonBeg) && (lon <= lonEnd);
} | java | {
"resource": ""
} |
q175290 | LatLonPointImpl.latToString | test | static public String latToString(double lat, int ndec) {
boolean is_north = (lat >= 0.0);
if (!is_north)
lat = -lat;
String f = "%."+ndec+"f";
Formatter latBuff = new Formatter();
latBuff.format(f, lat);
latBuff.format("%s", is_north ? "N" : "S");
return latBuff.toString();
} | java | {
"resource": ""
} |
q175291 | LatLonPointImpl.lonToString | test | static public String lonToString(double lon, int ndec) {
double wlon = lonNormal(lon);
boolean is_east = (wlon >= 0.0);
if (!is_east)
wlon = -wlon;
String f = "%."+ndec+"f";
Formatter latBuff = new Formatter();
latBuff.format(f, wlon);
latBuff.format("%s", is_east ? "E" : "W");
return latBuff.toString();
} | java | {
"resource": ""
} |
q175292 | BaseQuantity.compareTo | test | public int compareTo(final BaseQuantity that) {
int comp;
if (this == that) {
comp = 0;
}
else {
comp = getName().compareToIgnoreCase(that.getName());
if (comp == 0 && getSymbol() != null) {
comp = getSymbol().compareTo(that.getSymbol());
}
}
return comp;
} | java | {
"resource": ""
} |
q175293 | CatalogTreeView.getSelectedDataset | test | public DatasetNode getSelectedDataset() {
InvCatalogTreeNode tnode = getSelectedNode();
return tnode == null ? null : tnode.ds;
} | java | {
"resource": ""
} |
q175294 | CatalogTreeView.setSelectedDataset | test | public void setSelectedDataset(Dataset ds) {
if (ds == null) return;
TreePath path = makePath(ds);
if (path == null) return;
tree.setSelectionPath( path);
tree.scrollPathToVisible( path);
} | java | {
"resource": ""
} |
q175295 | CatalogTreeView.makeTreePath | test | TreePath makeTreePath(TreeNode node) {
ArrayList<TreeNode> path = new ArrayList<>();
path.add( node);
TreeNode parent = node.getParent();
while (parent != null) {
path.add(0, parent);
parent = parent.getParent();
}
Object[] paths = path.toArray();
return new TreePath(paths);
} | java | {
"resource": ""
} |
q175296 | CatalogTreeView.openAll | test | public void openAll( boolean includeCatref) {
if (catalog == null) return;
open( (InvCatalogTreeNode) model.getRoot(), includeCatref);
tree.repaint();
} | java | {
"resource": ""
} |
q175297 | CatalogTreeView.setCatalog | test | public void setCatalog(String location) {
CatalogBuilder builder = new CatalogBuilder();
try {
Catalog cat = builder.buildFromLocation(location, null);
setCatalog(cat);
} catch (Exception ioe) {
JOptionPane.showMessageDialog(this, "Error opening catalog location " + location+" err="+builder.getErrorMessage());
}
} | java | {
"resource": ""
} |
q175298 | CatalogTreeView.setCatalog | test | public void setCatalog(Catalog catalog) {
if (catalog == null) return;
String catalogName = catalog.getBaseURI().toString();
this.catalog = catalog;
// send catalog event
setCatalogURL( catalogName);
// display tree
// this sends TreeNode events
model = new InvCatalogTreeModel(catalog);
tree.setModel( model);
// debug
if (debugTree) {
System.out.println("*** catalog/showJTree =");
showNode(tree.getModel(), tree.getModel().getRoot());
System.out.println("*** ");
}
// look for a specific dataset
int pos = catalogName.indexOf('#');
if (pos >= 0) {
String id = catalogName.substring( pos+1);
Dataset dataset = catalog.findDatasetByID( id);
if (dataset != null) {
setSelectedDataset(dataset);
firePropertyChangeEvent( new PropertyChangeEvent(this, "Selection", null, dataset));
}
}
// send catalog event
firePropertyChangeEvent(new PropertyChangeEvent(this, "Catalog", null, catalogName));
} | java | {
"resource": ""
} |
q175299 | GDVConvention.findAlias | test | private String findAlias(NetcdfDataset ds, Variable v) {
String alias = ds.findAttValueIgnoreCase(v, "coord_axis", null);
if (alias == null)
alias = ds.findAttValueIgnoreCase(v, "coord_alias", "");
return alias;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.