Export only some bands from final product

Hi,

I am writing a stand alone script, using Sentinel 1 products as an input and I am applying the following steps:

  1. Get_sigma
  2. Create Subset
  3. Terrain correction
  4. Speckle filtering
  5. PCA

My final product returns 5 band and I would like to get only the component_1 for further analysis.

In order to do this I am either using the BandMaths dividing all values of component_1 with 1:

def getBand(file):

threshold = 1
expression = "component_1 / %s" % threshold
BandDescriptor = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor')
targetBand = BandDescriptor()
targetBand.name = 'component_1'
targetBand.type = 'Float32'
targetBand.expression = expression
targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 1)
targetBands[0] = targetBand
parameters = HashMap()
parameters.put('targetBands', targetBands)
band = GPF.createProduct('BandMaths', parameters, file)
return band

or I create a subset:

def subset(product):

HashMap = jpy.get_type('java.util.HashMap')
GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
parameters = HashMap()
parameters.put('sourceBands', 'component_1')
subset_band = GPF.createProduct('Subset', parameters, product)
return subset_band

Is there a more clever way to do this?