Weighting amount of overlapping polygons in postgis
It sounds like you want to intersect the flood shapefiles with the grid-cells, and then weight the precipitation by the proportion of the flood area that intersects each grid cell.
Step 1: Store the grid area.
ALTER TABLE precipitation_grid
ADD COLUMN grid_area DOUBLE PRECISION;
UPDATE TABLE precipitation_grid
SET grid_area = ST_AREA(geometry);
Step 2: Intersect, using ST_Intersects, ST_Intersection, and SELECT INTO
SELECT
g.cell_id,
f.gid,
ST_AREA(ST_INTERSECTION(g.geom, f.geom)) as x_area,
grid_area,
... other columns
INTO grid_flood_xsect
FROM precipitation_grid g,
flood_event_lib f
WHERE ST_INTERSECTS(g.geom, f.geom)
And then you can perform your calculations by weighting observations based on the area overlap, e.g.:
SELECT gid, cell_id, x_area / grid_area * some_value
FROM grid_flood_xsect