2013-10-15 61 views
3

我有一个复杂的NetCDF文件目录结构我想创建一个THREDDS目录。用于匹配目录的regExp

/data/buoy/A0121/realtime/A0121.met.realtime.nc 
         /A0121.waves.realtime.nc 
         etc. 
/data/buoy/A0122/realtime/A0122.met.realtime.nc 
         /A0122.sbe37.realtime.nc 
         etc. 
/data/buoy/B0122/realtime/B0122.met.realtime.nc 
         /B0122.sbe37.realtime.nc 
etc. 

但我发现,在这两种datasetScan和汇聚/扫描元件的正则表达式属性似乎没有能够处理使用正则表达式的子目录。例如,此商品的作品。

<datasetScan name="All TEST REALTIME" ID="all_test_realtime" path="/All/Realtime" 
    location="/data/buoy/B0122" > 
    <metadata inherited="true"> 
    <serviceName>all</serviceName> 
    </metadata> 
    <filter> 
    <include regExp="realtime" atomic="false" collection="true" /> 
    <include wildcard="*.nc" /> 
    <!-- exclude directory --> 
    <exclude wildcard="old" atomic="false" collection="true" /> 
    </filter> 
</datasetScan> 

但是下面没有。没有找到数据集。

<datasetScan name="All TEST REALTIME" ID="all_test_realtime" path="/All/Realtime" 
    location="/data/buoy" > 
    <metadata inherited="true"> 
    <serviceName>all</serviceName> 
    </metadata> 
    <filter> 
    <include regExp="B0122/realtime" atomic="false" collection="true" /> 
    <include wildcard="*.nc" /> 
    <!-- exclude directory --> 
    <exclude wildcard="old" atomic="false" collection="true" /> 
    </filter> 
</datasetScan> 

这是一个大大简化例子只是做了确认,正则表达式不匹配,这是在这个ncML页面底部暗示的子目录。 http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/ncml/v2.2/AnnotatedSchema4.html

我真正的目标是通过<扫描正则表达式= “使用ncML聚合” >

我应该使用FeatureCollections?这些非常简单的时间序列浮标观测文件。

回答

3
<filter> 
    <include regExp="[A-Z]{1}[0-9]{4}" atomic="false" collection="true" /> 
    <include wildcard="realtime" atomic="false" collection="true" /> 
    <include wildcard="post-recovery" atomic="false" collection="true" /> 
    <include wildcard="*.nc" /> 
    <!-- exclude directory --> 
    <exclude wildcard="old" atomic="false" collection="true" /> 
</filter> 
3

如果您在扫描文件的<aggregation>并且要包含子目录,您可以添加subdirs="true"<scan>元素中,例如:

<?xml version="1.0" encoding="UTF-8"?> 
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"> 
    <aggregation dimName="ocean_time" type="joinExisting"> 
     <scan location="." regExp=".*vs_his_[0-9]{4}\.nc$" subdirs="true"/>   
    </aggregation> 
</netcdf> 

对于datasetScan数据集,正则表达式过滤器会自动应用到所有子目录,所以如果你想这些过滤器适用于所有子目录,你可以只是做:

<datasetScan name="All TEST REALTIME" ID="all_test_realtime" path="/All/Realtime" 
    location="/data/buoy" > 
    <metadata inherited="true"> 
    <serviceName>all</serviceName> 
    </metadata> 
    <filter> 
    <include regExp="realtime" atomic="false" collection="true" /> 
    <include wildcard="*.nc" /> 
    <!-- exclude directory --> 
    <exclude wildcard="old" atomic="false" collection="true" /> 
    </filter> 
</datasetScan> 
+0

我意识到subdirs被搜索。我的问题真的是为什么regExp =“realtime”有效,regExp =“B0122/realtime”没有。我发现在数据集扫描和扫描regExp属性中都是这种情况。我一直希望利用现有的目录结构来限制搜索到的子目录的数量。幸运的是在我的情况下,文件名包含了找到我所需要的所有信息。 –

+0

您是否尝试过'regExp =“。* B0112/realtime”'?如果这有效,那就表明'regExp'正在处理全路径名。但是,似乎更有可能'regExp'正在处理本地目录或文件名,因此它从不会找到匹配'B0122/realtime' –

+0

我尝试过regExp =“。* B0122/realtime”,但没有运气。我已经通过列表向Unidata开发者提出了这个问题,我认为你是正确的。这是有道理的编程。走路径并检查找到的文件名与regExp。使用两个过滤器/包含我确实取得了成功。见下面的例子。 –