An error was reported when snappy was used to process the Enhanced Spectral Diversity process. Unparseable date: "29Dec2021"

import os
import esa_snappy
from esa_snappy import ProductIO, GPF, HashMap, jpy

获取 Java 类型

Integer = jpy.get_type(‘java.lang.Integer’)
Double = jpy.get_type(‘java.lang.Double’) # 定义 Double 类型

读取产品

def read_product(product_path):
try:
return ProductIO.readProduct(product_path)
except Exception as e:
print(f"读取产品时出错: {e}")
exit(1)

应用 Enhanced Spectral Diversity (ESD)

def apply_esd(product):
try:
parameters = HashMap()

    # 根据截图中的参数进行配置
    parameters.put('registrationWindowWidth', Integer(512))
    parameters.put('registrationWindowHeight', Integer(512))
    parameters.put('searchWindowAccuracyAzimuth', Integer(16))
    parameters.put('searchWindowAccuracyRange', Integer(16))
    parameters.put('windowOversamplingFactor', Integer(128))
    parameters.put('crossCorrelationThreshold', Double(0.1))
    parameters.put('coherenceThreshold', Double(0.3))
    parameters.put('numWindowsPerOverlap', Integer(10))
    parameters.put('esdEstimator', 'Periodogram')
    parameters.put('weightFunction', 'Inv Quadratic')
    parameters.put('temporalBaselineType', 'Number of images')
    parameters.put('maxTemporalBaseline', 'Number of images')
    parameters.put('integrationMethod', 'L1 and L2')
    parameters.put('overallRangeShift', Double(0.0))
    parameters.put('overallAzimuthShift', Double(0.0))

    # 执行 ESD 操作
    return GPF.createProduct('Enhanced-Spectral-Diversity', parameters, product)
except Exception as e:
    print(f"应用 ESD 时出错: {e}")
    exit(1)

保存产品

def save_product(product, output_path):
try:
if os.path.exists(output_path):
os.remove(output_path)
ProductIO.writeProduct(product, output_path, ‘BEAM-DIMAP’)
except Exception as e:
print(f"保存产品时出错: {e}")
exit(1)

数据处理流程

def process_esd(input_files, output_path):
for input_file in input_files:
# 读取产品
product = read_product(input_file)

    # 应用 Enhanced Spectral Diversity (ESD)
    esd_applied_product = apply_esd(product)
    
    # 设置输出文件路径
    output_file_name = os.path.basename(input_file).replace('.dim', '_esd.dim')
    esd_output_file_path = os.path.join(output_path, output_file_name)
    
    # 保存处理后的产品
    save_product(esd_applied_product, esd_output_file_path)

路径定义

input_path = ‘/data/data/snap/menyuan_GUI/output_GUI_snappy’
output_path = input_path # 输出路径与输入路径相同

获取配准后的文件列表

input_files = [os.path.join(input_path, f) for f in os.listdir(input_path) if f.endswith(‘_Stack.dim’)]

确保输出路径存在

os.makedirs(output_path, exist_ok=True)

运行数据处理流程

process_esd(input_files, output_path)

INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
Unparseable date: “29Dec2021”
应用 ESD 时出错: org.esa.snap.core.gpf.OperatorException: Unparseable date: “29Dec2021”
(DInSAR) administrator@g220:/data/wangfengmao_file/aipy/py$
Is this error normal? How should it be solved?

Hi Wang Feng Mao,

does this happen for every product in your list of inputs?

What kind of products are these? Can you open/read them in SNAP Desktop? For a more detailed check, could you provide an example product?

Thanks a lot,
Olaf

Thank you very much.I found a solution to the problem you were facing earlier.I changed the Chinese languag to English on my desktop ,and the error no longer occurs.

All kind of products are these and I can open/read them in SNAP Desktop.