Exemplo n.º 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);
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 4
0
Arquivo: misc.py Projeto: 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"
Exemplo n.º 5
0
Arquivo: misc.py Projeto: 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";