예제 #1
0
def filterMaps(mapSets, propName,operator,value):
        """Return a new set of maps whose property propName satisfies the given operator/value.
        The operators can be ==,!=, <,>,<=,>=, match, !match"""
        from ucar.visad import ShapefileAdapter
        from ucar.unidata.util import StringUtil
	goodOnes = java.util.ArrayList();
	sets = mapSets.getSets();
        for mapIdx in xrange(len(sets)):
		mapValue =  getMapProperty(sets[mapIdx],propName);
		if(mapValue is None):
			continue;
		if(operator== '==' and mapValue == value):
			goodOnes.add(sets[mapIdx]);
		elif(operator== '!=' and mapValue != value):
			goodOnes.add(sets[mapIdx]);
		elif(operator== '<' and mapValue < value):
			goodOnes.add(sets[mapIdx]);
		elif(operator== '<=' and mapValue <= value):
			goodOnes.add(sets[mapIdx]);
		elif(operator== '>' and mapValue > value):
			goodOnes.add(sets[mapIdx]);
		elif(operator== '>=' and mapValue >= value):
			goodOnes.add(sets[mapIdx]);
		elif(operator== 'match' and StringUtil.stringMatch(str(mapValue), value)):
			goodOnes.add(sets[mapIdx]);
		elif(operator== '!match' and not StringUtil.stringMatch(str(mapValue), value)):
			print "not match: " + mapValue;
			goodOnes.add(sets[mapIdx]);

	return ShapefileAdapter.makeSet(goodOnes);
예제 #2
0
 def call(self):
     self.thread_used = threading.currentThread().getName()
     try:
         reader = AddeTextReader(self.url)
         if reader.getStatusCode() > 0:
             lines = StringUtil.listToStringArray(reader.getLinesOfText())
             self.result = AddeSatBands(lines)
     except Exception, ex:
         self.exception = ex
예제 #3
0
 def call(self):
     self.thread_used = threading.currentThread().getName()
     try:
         reader = AddeTextReader(self.url)
         if reader.getStatusCode() > 0:
             lines = StringUtil.listToStringArray(reader.getLinesOfText())
             self.result = AddeSatBands(lines)
     except Exception, ex:
         self.exception = ex
예제 #4
0
파일: misc.py 프로젝트: DINKIN/IDV
def printSounding(sounding):
    """ Print out the values of the sounding data """
    from ucar.unidata.util import StringUtil
    numFields = sounding.getDimension()
    dateTime = sounding.getComponent(0)
    location = sounding.getComponent(1)
    print "date:" + str(dateTime)
    print "location:" + str(location)

    for fieldIdx in range(2, numFields):
        rowBuffers = ArrayList()
        sb = java.lang.StringBuffer()
        rowBuffers.add(sb)
        field = sounding.getComponent(fieldIdx)
        rangeType = field.getType().getRange()
        domainSamples = field.getDomainSet().getSamples()
        a
        rows = field.getDomainSet().getLength()
        fieldName = str(field.getType().getRange())
        domainType = field.getDomainSet().getType().getDomain()
        sb.append(str(domainType))
        sb.append(", ")
        fieldName = fieldName.replace("(", "")
        fieldName = fieldName.replace(")", "")
        sb.append(fieldName)
        for row in range(rows):
            sb = java.lang.StringBuffer()
            rowBuffers.add(sb)
            sb.append(str(domainSamples[0][row]))
            sb.append(", ")
            data = field.getSample(row)
            dataString = str(data)
            # a hack to deal with the spd/dir tuple
            dataString = dataString.replace("(", "")
            dataString = dataString.replace(")", "")
            sb.append(dataString)
        print StringUtil.join("\n", rowBuffers)
        print "\n\n"
예제 #5
0
파일: misc.py 프로젝트: jon4than/IDV
def printSounding(sounding):
        """ Print out the values of the sounding data """
        from ucar.unidata.util import StringUtil;
        numFields = sounding.getDimension();
        dateTime = sounding.getComponent(0);
        location = sounding.getComponent(1);
        print "date:" + str(dateTime);
        print "location:" + str(location);

        for fieldIdx in range(2,numFields):
                rowBuffers =  ArrayList();
                sb = java.lang.StringBuffer();
                rowBuffers.add(sb);
                field = sounding.getComponent(fieldIdx);
                rangeType= field.getType().getRange();
                domainSamples = field.getDomainSet().getSamples();a
                rows = field.getDomainSet().getLength();
                fieldName= str(field.getType().getRange());
                domainType = field.getDomainSet().getType().getDomain();
                sb.append(str(domainType));
                sb.append(", ");
                fieldName = fieldName.replace("(","");
                fieldName = fieldName.replace(")","");
                sb.append(fieldName);
                for row in range(rows):
                        sb = java.lang.StringBuffer();
                        rowBuffers.add(sb);
                        sb.append(str(domainSamples[0][row]));
                        sb.append(", ");
                        data = field.getSample(row);
                        dataString = str(data);
                        # a hack to deal with the spd/dir tuple
                        dataString = dataString.replace("(","");
                        dataString = dataString.replace(")","");
                        sb.append(dataString);
                print StringUtil.join("\n",rowBuffers);
                print "\n\n";